我有一个课程和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