Logback的主要模块
- logback-access
- logback-classic
- logback-core
Logback的主要标签
Logback的配置
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<configuration debug="false">
<appender name="INFO-FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${catalina.base}/webapps/o2o/logs/info/info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${catalina.base}/webapps/o2o/logs/info/info.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>1024MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>30</maxHistory>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{55} -
%msg%n
</pattern>
</layout>
</appender>
<appender name="ACCESS-FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>
${catalina.base}/webapps/o2o/logs/access/access.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${catalina.base}/webapps/o2o/logs/access/access.%d{yyyy-MM-dd}.%i.log.zip</FileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>1024MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>30</maxHistory>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{55} -
%msg%n
</pattern>
</layout>
</appender>
<logger name="com.imooc.o2o" level="DEBUG" additivity="false">
<appender-ref ref="ACCESS-FILE" />
</logger>
<root level="INFO">
<appender-ref ref="INFO-FILE" />
</root>
</configuration>
网友评论