英文:
How to send logs with different levels to different appenders using log4j2.properties file?
问题
我正在使用log4j2
,并且尝试让不同的日志消息进入同一记录器中的不同附加器。这种情况在log4j2常见问题中有详细描述,但我需要使用log4j2.properties配置文件,而不是示例中给出的XML配置。
另一个带有XML配置文件的示例可以在这里找到 - 基本上,我不知道如何在log4j2.properties
语法中指定以下行:
<AppenderRef ref="Console" level="info"/>
<AppenderRef ref="hibernateFile" level="debug"/>
英文:
I'm using log4j2
and am trying to have different log messages go to different appenders within the same logger. This case is described exactly in the log4j2 FAQ - but I need to use the log4j2.properties configuration file instead of the XML configuration given in the example.
Another example with an XML configuration file is given here - essentially, I don't know how to specify the lines
<AppenderRef ref = "Console" level ="info"/>
<AppenderRef ref = "hibernateFile" level = "debug"/>
in log4j2.properties
syntax.
答案1
得分: 1
以下是翻译好的内容:
你可以尝试以下语法 -
rootLogger.level = trace
rootLogger.appenderRef.file.ref = file
rootLogger.appenderRef.file.level = DEBUG
rootLogger.appenderRef.stdout.ref = STDOUT
rootLogger.appenderRef.stdout.level = INFO
英文:
You can try below syntax -
rootLogger.level = trace
rootLogger.appenderRef.file.ref = file
rootLogger.appenderRef.file.level = DEBUG
rootLogger.appenderRef.stdout.ref = STDOUT
rootLogger.appenderRef.stdout.level = INFO
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论