使用一个log4j2.properties的2个日志文件

时间:2018-12-21 07:04:16

标签: java logging log4j2

我有一个课程和2个记录器,如下所示。想使用log4j2.properties创建main.log和recon.log文件。

我正在尝试下面的方法仅对一个记录器起作用,如何将第二个记录器添加到相同的log4j2.properties?

final static Logger mainlog = LogManager.getLogger("mainlogger");
final static Logger reconlog = LogManager.getLogger("reconlogger"); 

name=PropertiesConfig
property.filename = logs
appenders = console, file
property.basePath = ./logs/
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %msg%n
appender.file.type = File
appender.file.name = LOGFILE
appender.file.fileName=${basePath}/recon.log
appender.file.layout.type=PatternLayout
appender.file.layout.pattern= %msg%n
loggers=file
logger.file.name=reconlogger
logger.file.level = debug
logger.file.appenderRefs = file
logger.file.appenderRef.file.ref = LOGFILE
rootLogger.level = debug
rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = STDOUT

0 个答案:

没有答案