logback.xml 在普通 Java 项目中被忽略

Suz*_*ioc 1 java logging logback slf4j

显然,我的 Java 项目中没有发生日志记录。logback.xml文件位于类路径中,但显然被忽略了。没有报告有关此文件的任何错误。

JAR 以下列方式附加(使用 Maven):

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.0.13</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

以下消息出现在控制台中:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:MYREPO/org/slf4j/slf4j-simple/1.7.5/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:MYREPO/ch/qos/logback/logback-classic/1.0.13/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
Run Code Online (Sandbox Code Playgroud)

显然,这两个 jar 都是由单个 Maven 条目引用的。

Sot*_*lis 5

你好像有

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.5</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

摆脱它。logback已经提供了您需要的课程。