我想使用Lombok @Log
或@Slf4j
,但是当我创建:
@Log
public class Test{
public Test(){
log.error("Something's wrong here");
}
}
在日志中,我没有错误方法。我有info
和warning
我只有log()
方法。
我尝试将mave依赖添加到Slf4j库,但它没有帮助。
答案 0 :(得分:0)
我发现spring boot自动包含libries。我将这些库添加到我的非春季项目中并且一切正常
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>
LogTest
@Slf4j
@NoArgsConstructor
@Data
public class LogTest {
public void test(){
log.error("fdfzsdf");
}
}