码迷,mamicode.com
首页 > 编程语言 > 详细

springboot配置log4j

时间:2017-10-31 21:29:07      阅读:397      评论:0      收藏:0      [点我收藏+]

标签:release   eve   this   levels   group   .com   oge   inf   sys   

     <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${spring.boot.version}</version>
            <exclusions>
                <exclusion>
                    <artifactId>log4j-over-slf4j</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>
         <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j</artifactId>
            <version>1.3.8.RELEASE</version>
        </dependency>

log4j.properties

project=datasight
logdir=/home/logs/${project}

### set log levels ###
log4j.rootLogger = info,stdout
# config this project appender,log level:info,error #
log4j.logger.com.ts.report = info,error,bizInfo,bizError

### 控制台输出 ###  
log4j.appender.stdout=org.apache.log4j.ConsoleAppender  
log4j.appender.stdout.Target=System.out  
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout  
log4j.appender.stdout.layout.ConversionPattern=%d{yyy-MM-dd HH\:mm\:ss} %5p %c{1}\:%L - %m%n 

# info log everyday file#
log4j.loger.bizInfo = info,bizInfo
log4j.appender.bizInfo=org.apache.log4j.DailyRollingFileAppender  
log4j.appender.bizInfo.File=${logdir}/info.log 
log4j.appender.bizInfo.layout=org.apache.log4j.PatternLayout  
log4j.appender.bizInfo.DatePattern=_yyyy-MM-dd
log4j.appender.bizInfo.layout.ConversionPattern=%d{yyy-MM-dd HH\:mm\:ss} %5p %c{1}\:%L - %m%n 
log4j.appender.bizInfo.Threshold=INFO 
#log4j.additivity.bizInfo=false  

##  error log ##
log4j.loger.bizError = info,bizError
log4j.appender.bizError = org.apache.log4j.DailyRollingFileAppender
log4j.appender.bizError.File = ${logdir}/error.log
log4j.appender.bizError.layout = org.apache.log4j.PatternLayout
log4j.appender.bizError.DatePattern=_yyyy-MM-dd
log4j.appender.bizError.layout.ConversionPattern =%d{yyy-MM-dd HH\:mm\:ss} %5p %c{1}\:%L - %m%n 
log4j.appender.bizError.Threshold = ERROR
#log4j.additivity.error=false

 

springboot配置log4j

标签:release   eve   this   levels   group   .com   oge   inf   sys   

原文地址:http://www.cnblogs.com/qixing/p/7763582.html

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