因此,问题是如何在Java代码中动态添加AsyncLogger?我想得到的是:
<AsyncLogger name="io.example" level="info" additivity="false">
<AppenderRef ref="RollingFile"/>
</AsyncLogger>对于同步记录器,我通常使用:
LoggerContext context = (LoggerContext) LogManager.getContext(false);
Configuration configuration = context.getConfiguration();
// creating logConfig
configuration.addLogger(packageName, loggerConfig);但我找不到任何“异步”选项。也许我应该使用另一种类型的LoggerContext?或者使用某种特定类型的LoggerConfig?
另外,我想同时有"sycn“和"async”记录器,所以设置所有的记录器为"async“不是我的选择。
请帮帮我!
发布于 2016-12-06 23:28:43
这是关于这个问题的官方Log4J2文档:Programmatically Modifying the Current Configuration after Initialization
https://stackoverflow.com/questions/40992409
复制相似问题