Fork me on GitHub

解决springboot打不出业务log

今天不知道咋回事,单独的module可以打出log,而start的web工程始终打不出来,直觉就是jar包冲突,log的包太多了,logback自己跪了,后来经过尝试,得出如下的组合pom,不妨一试。

      <dependencies>
           <!--log--> 
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>1.1.11</version>
            </dependency>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-core</artifactId>
                <version>1.2.3.5-struct</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.7.25</version>
            </dependency>
            <dependency>
                <groupId>org.logback-extensions</groupId>
                <artifactId>logback-ext-spring</artifactId>
                <version>0.1.5</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>jcl-over-slf4j</artifactId>
                <version>1.7.25</version>
            </dependency>
            <!--想办法排除掉log4j-over-slf4j,999-not-exist-SNAPSHOT自己整一个空包也行,塞到maven私服/本地仓库--> 
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>log4j-over-slf4j</artifactId>
                <version>999-not-exist-SNAPSHOT</version>
            </dependency>
            <dependency>
                <groupId>net.logstash.logback</groupId>
                <artifactId>logstash-logback-encoder</artifactId>
                <version>5.3</version>
            </dependency>
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
                <version>1.2.17</version>
            </dependency>
            <!--log end-->
        </dependencies>

如上的组合,顺利打出了log,还得检查下自己的logback-spring的配置文件,是否有打印级别控制,最好是设置在debug级别,方便调试。

posted @ 2021-08-16 11:33  _落雨  阅读(223)  评论(0编辑  收藏  举报