码迷,mamicode.com
首页 > 其他好文 > 详细

logback配置

时间:2014-07-27 22:53:29      阅读:264      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   文件   io   for   div   

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MyApp {
    final static Logger logger = LoggerFactory.getLogger("MyApp.class");
    public static void main(String[] args) {
        logger.trace("trace");
        logger.debug("debug");
        logger.info("info");
        logger.warn("warn");
        logger.error("error");
        System.out.println(111);
    }
}
<configuration>
    <property name="LOG_FORMAT" value="%date [%thread] %-5level %logger - %msg%n%rEx" />
    <property name="CHARSET" value="UTF-8" />

    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">//输出到控制台
        <encoder>
            <pattern>%date [%thread] %-5level (%file:%line\) - %msg%n</pattern>//输出格式
            <charset>${CHARSET}</charset>
        </encoder>
    </appender>

    <appender name="file—info"
        class="ch.qos.logback.core.rolling.RollingFileAppender">//输出到文件
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>D:/logs/info.%d{yyyy-MM-dd}.log</FileNamePattern>
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>%date [%thread] %-5level (%file:%line\) - %msg%n</pattern>
            <charset>${CHARSET}</charset>
        </encoder>
    </appender>

    <root level="info">
        <appender-ref ref="stdout" />
        <appender-ref ref="file—info" />
    </root>

</configuration>

 

logback配置,布布扣,bubuko.com

logback配置

标签:style   blog   color   os   文件   io   for   div   

原文地址:http://www.cnblogs.com/sunfan1988/p/3871742.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!