Lombok @Log和@ Slf4j没有错误方法

时间:2017-02-21 11:43:36

标签: java logging slf4j

我想使用Lombok @Log@Slf4j,但是当我创建:

@Log
public class Test{
    public Test(){
       log.error("Something's wrong here");
    }
}

在日志中,我没有错误方法。我有infowarning

我只有log()方法。

我尝试将mave依赖添加到Slf4j库,但它没有帮助。

1 个答案:

答案 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");
        }
    }