springboot配置log4j
Posted 七星6609
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot配置log4j相关的知识,希望对你有一定的参考价值。
<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的主要内容,如果未能解决你的问题,请参考以下文章