1. 使用logback 0.9.7版本,我在使用logback0.9.5版本时不支持
2. 配置实例如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<substitutionProperty name="log.base" value="logs" />
<jmxConfigurator />
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date [%thread] %-5level %logger{80} - %msg%n</pattern>
</layout>
</appender>
<appender name="logfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<Encoding>UTF-8</Encoding>
<File>${log.base}/cds.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${log.base}/cds-%d{yyyy-MM-dd}-%i.log</FileNamePattern>
<MaxHistory>10</MaxHistory>
<TimeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<MaxFileSize>2MB</MaxFileSize>
</TimeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%date [%thread] %-5level %logger{80} - %msg%n</pattern>
</layout>
</appender>
<logger name="org.springframework">
<level value="INFO" />
</logger>
<logger name="org.apache.ftpserver">
<level value="WARN" />
</logger>
<logger name="org.hibernate">
<level value="INFO" />
</logger>
<logger name="org.hibernate.SQL">
<level value="ERROR" />
</logger>
<logger name="org.hibernate.cache">
<level value="INFO" />
</logger>
<logger name="org.safehaus.asyncweb">
<level value="INFO" />
</logger>
<logger name="org.logicalcobwebs.proxool">
<level value="DEBUG" />
</logger>
<root>
<level value="WARN" />
<appender-ref ref="stdout" />
<appender-ref ref="logfile" />
</root>
</configuration>