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