logback.xml配置
发布网友
发布时间:2022-05-01 21:55
我来回答
共1个回答
热心网友
时间:2022-06-24 01:18
开发环境
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%-20(%d{HH:mm:ss.SSS} [%thread]) %-5level %logger{80} - %msg%n</pattern>
</layout>
</appender>
<logger name="java.sql.PreparedStatement" level="DEBUG" />
<logger name="org.springframework.ui.freemarker" level="DEBUG" />
<root level="INFO">
<appender-ref ref="stdout" />
</root>
</configuration>
生产环境
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/xxx.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/xxx.%d{yyyy-MM-dd}.log.zip</fileNamePattern>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%-20(%d{HH:mm:ss.SSS} [%thread]) %-5level %logger{80} - %msg%n</pattern>
</layout>
</appender>
<root level="WARN">
<appender-ref ref="file" />
</root>
</configuration>