log4j升级为log4j2(无需修改代码)

1.Tomcat\webapps\app\WEB-INF\lib目录下删除有关log4j的jar包

log4j-1.2.8.jar、slf4j-api-1.5.6.jar(版本有所不同,通过jar包开头确定log4j jar包)

 

2.Tomcat\webapps\app\WEB-INF\lib目录下添加log4j2相关jar包

log4j-api-2.13.0.jar、log4j-1.2-api-2.13.0.jar、log4j-core-2.13.0.jar

 

3.Tomcat\webapps\app\WEB-INF\classes目录下删除log4j配置文件

log4j.properties

 

4.Tomcat\webapps\app\WEB-INF\classes目录下添加log4j2配置文件

log4j.xml或者log4j2.properties

附上log4j2.properties配置

 

status = warn
name = MyApp

#指定输出源‘类型’为控制台
appender.console.type = Console
appender.console.name = consoleLogDemo
appender.console.filter.threshold.type = ThresholdFilter
appender.console.filter.threshold.level = debug
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%-5p] [%d{yyyy-MM-dd HH:mm:ss}] [%C{1}:%M:%L] %m%n
appender.console.target = System_out

appender.rolling.type = RollingFile
appender.rolling.name = fileLogDemo
appender.rolling.filter.threshold.type = ThresholdFilter
appender.rolling.filter.threshold.level = info
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = [%-5p] [%d{yyyy-MM-dd HH:mm:ss}] [%C{1}:%M:%L] %m%n
appender.rolling.append = true
appender.rolling.fileName =/data/logs/workflow/web.log
appender.rolling.filePattern=/data/logs/wokflow/web.log.%d{yyyy-MM-dd}
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 2
appender.rolling.policies.time.modulate = true
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size=100MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 5


logger.rolling.name = com.iqiyi
logger.rolling.level = info
logger.rolling.additivity = false
logger.rolling.appenderRef.rolling.ref = fileLogDemo

#指明根级日志的级别
rootLogger.level = info
#指定哪些appender输出源是根级日志的输出级别
rootLogger.appenderRef.consolelogdemo.ref = consoleLogDemo
rootLogger.appenderRef.filelogdemo.ref = fileLogDemo


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值