logback
<configuration>
<!-- 输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>%d{dd-MM-YYYY HH:mm:ss.SSS} %-5level %c{0} - %msg %n</pattern>
</encoder>
</appender>
<!-- Strictly speaking, the level attribute is not necessary since -->
<!-- the level of the root level is set to DEBUG by default. -->
<root level="DEBUG">
<appender-ref ref="CONSOLE" />
</root>
<!-- 输出到指定路径下的指定文件-->
<appender name="fileAppender" class="ch.qos.logback.core.FileAppender">
<file>/logs/granularity.log</file>
<encoder>必须指定,否则不会往文件输出内容
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
</encoder>
<append>true</append>
<prudent>false</prudent>
</appender> -->
<root level="DEBUG">
<appender-ref ref="fileAppender" />
</root>
<!-- 输出到指定路径下的指定文件,按照天数回滚删除-->
<appender name="rollingAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>D:/project/logs/application-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder><!-- 必须指定,否则不会往文件输出内容 -->
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
</encoder>
<append>false</append>
<prudent>false</prudent>
</appender>
<root level="DEBUG">
<appender-ref ref="rollingAppender" />
</root>
</configuration>
参考url===http://www.thinksaas.cn/topics/0/99/99480.html