Logback 文件不记录所有类和所有详细信息的信息
删除 Log4j 并通过 lombok 实现实现 logback 后,我面临着奇怪的情况。
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ClassA{
public void executeCode(){
log.info("Hello world");
}
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ClassB{
public void executeCode(){
log.info("Hello stack members");
}
logback xml 文件如下所示:
<configuration scan="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>utf-8</charset>
<pattern>%boldMagenta(%d{yyyy-MM-dd' 'HH:mm:ss,SSS}) %highlight(%level)-> %msg%n</pattern>
</encoder>
</appender>
<appender name="LOGS_HTML" class="ch.qos.logback.core.FileAppender">
<file>logs/log.html</file>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.html.HTMLLayout">
<pattern>%thread%level%logger%msg</pattern>
</layout>
</encoder>
</appender>
<appender name="ROLLING_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>60</maxHistory>
<totalSizeCap>30GB</totalSizeCap>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{HH:mm:ss} [%thread] %-5level - %msg%n</pattern>
</encoder>
<file>logs/file.log</file>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="LOGS_HTML"/>
<appender-ref ref="ROLLING_FILE"/>
</root>
file.log 附加到 Allure 报告中,但运行后,该文件不存储正确的执行情况。显示一些以前的运行,但不显示与当前运行有关的任何内容。 即使我删除历史记录实现,日志也不会完全显示,并且显示的日志仅来自 ClassA
我需要显示当前执行期间的所有日志,仅此而已,来自项目中可用的所有类。
I'm facing a weird situation after removing Log4j and implemented logback via lombok implementation.
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ClassA{
public void executeCode(){
log.info("Hello world");
}
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ClassB{
public void executeCode(){
log.info("Hello stack members");
}
The logback xml file looks like:
<configuration scan="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<charset>utf-8</charset>
<pattern>%boldMagenta(%d{yyyy-MM-dd' 'HH:mm:ss,SSS}) %highlight(%level)-> %msg%n</pattern>
</encoder>
</appender>
<appender name="LOGS_HTML" class="ch.qos.logback.core.FileAppender">
<file>logs/log.html</file>
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="ch.qos.logback.classic.html.HTMLLayout">
<pattern>%thread%level%logger%msg</pattern>
</layout>
</encoder>
</appender>
<appender name="ROLLING_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>60</maxHistory>
<totalSizeCap>30GB</totalSizeCap>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>100MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{HH:mm:ss} [%thread] %-5level - %msg%n</pattern>
</encoder>
<file>logs/file.log</file>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="LOGS_HTML"/>
<appender-ref ref="ROLLING_FILE"/>
</root>
The file.log is attached to an Allure report, but after run, the file doesn't store the correct execution. Displays some previous runs, and nothing regarding the current one.
Even if I remove the history implementation, the logs are not fully displayed, and those displayed are only from ClassA
I need to display all logs during current execution, and nothing more, from all classes available in project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论