此 logback.xml 正在记录到文件但无法登录到控制台?我希望有人能在这个配置中发现配置错误?这是我的基本记录器配置:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
...
public static Logger logger = LoggerFactory.getLogger( "JUnit" );
...
logger.info("This comment fails to show in console but it shows in log file");
这是 logback.xml :
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>junitOut.log</file>
<append>false</append>
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%-4r %-5level %logger{35}: %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="FILE" />
</root>
<!-- We want error logging from this logger to go to an extra appender
It still inherits CONSOLE STDOUT from the root logger -->
<logger name="junitOut" level="INFO">
<appender-ref ref="STDOUT" />
</logger>
</configuration>