首先它现在可以正常工作了。我需要打印错误,所以我的登录配置是这样:
<configuration>
<!-- Appenders -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%-5level - %class.%method :
%line] %msg %n</pattern>
</encoder>
</appender>
<appender name="file" class="ch.qos.logback.core.FileAppender">
<file>C:\Work\xxx\xxx\src\main\resources\logs\logFile.log</file>
<append>true</append>
<!-- set immediateFlush to false for much higher logging throughput -->
<immediateFlush>true</immediateFlush>
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%-5level - %class.%method :
%line] %msg %n</pattern>
</encoder>
</appender>
<!-- Logger for my project -->
<logger name="example">
<appender-ref ref="console" />
<appender-ref ref="file" />
</logger>
<root level="error">
<appender-ref ref="console" />
<appender-ref ref="file" />
</root>
</configuration>
logback.xml
在此路径/src/main/resources/
中,日志文件位于/src/main/resources/logs/logFile.log
中。发生异常后,它会在文件中打印我的日志,现在它确实不起作用。有人可以帮助我吗?