首页 > 代码库 > logback配置
logback配置
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=http://www.mamicode.com/"%date [%thread] %-5level %logger - %msg%n%rEx" /> <property name="CHARSET" value=http://www.mamicode.com/"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>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。