<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 控制台 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!-- <pattern>${CONSOLE_LOG_PATTERN}</pattern> -->
<pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
<charset>utf8</charset>
</encoder>
</appender> <appender name="serviceAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 日志文件名称 -->
<File>logs/com.luna.service.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天一个日志文件
当前日志文件名是上面指定的文件名logFile.log,归档日志文件名格式如下 -->
<fileNamePattern>logs/com.luna.service-%d{yyyy-MM-dd}.log.zip</fileNamePattern>
<!-- 保存最近30天的日志 -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd} %d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
<charset>utf8</charset>
</encoder>
</appender> <appender name="daoAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 日志文件名称 -->
<File>logs/com.luna.mapper.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天一个日志文件
当前日志文件名是上面指定的文件名logFile.log,归档日志文件名格式如下 -->
<fileNamePattern>logs/com.luna.mapper-%d{yyyy-MM-dd}.log.zip</fileNamePattern>
<!-- 保存最近30天的日志 -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd} %d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
<charset>utf8</charset>
</encoder>
</appender> <logger name="com.luna.service" level="DEBUG" >
<appender-ref ref="serviceAppender" />
</logger> <logger name="com.luna.mapper" level="DEBUG" >
<appender-ref ref="daoAppender" />
</logger> <root level="debug">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
这个帖子也比较详细:http://czj4451.iteye.com/blog/1975937