美文网首页
slf4j-api log4j关系总结

slf4j-api log4j关系总结

作者: 清醒时分 | 来源:发表于2020-05-02 08:30 被阅读0次

    常用的log包

    image.png
    image.png
    image.png

    常用maven依赖

    SLF4j

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </dependency>
    

    log4j2

            <!--> 桥接包 <-->
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-slf4j-impl</artifactId>
            </dependency>
            <!--> log4j2 <-->
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
            </dependency>
    

    如果想从log4j升级到log4j2,并且不用变更代码可以引用下面的配置

            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-1.2-api</artifactId>
            </dependency>
    

    log4j

             <!--> 桥接包 <-->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </dependency>
             <!--> log4j2 <-->
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </dependency> 
    

    FIY

    https://www.cnblogs.com/chenhongliang/p/5312517.html

    相关文章

      网友评论

          本文标题:slf4j-api log4j关系总结

          本文链接:https://www.haomeiwen.com/subject/zyvhghtx.html