gpt4 book ai didi

java - 无法将 Log4j2 AsyncAppender 与 log4j2.properties 一起使用

转载 作者:搜寻专家 更新时间:2023-11-01 03:45:46 27 4
gpt4 key购买 nike

我已将 log4j2.properties 定义为

    ...
appender.async.type = Async
appender.async.name = async
appender.async.appenderRefs.type = AppenderRefs
appender.async.appenderRefs.consoleAppender.type = AppenderRef
appender.async.appenderRefs.consoleAppender.ref = console

rootLogger.level = debug
rootLogger.appenderRef.console.ref = async
rootLogger.appenderRef.rolling.ref = rolling

运行时异常:

2019-06-28 12:03:27,996 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.AsyncAppender for element Async: java.lang.NullPointerException java.lang.NullPointerException
at org.apache.logging.log4j.core.config.plugins.visitors.PluginElementVisitor.visit(PluginElementVisitor.java:52)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:180)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:121)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:964)

...

2019-06-28 12:03:27,997 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.AsyncAppender for element Async: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.AsyncAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.AsyncAppender
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:234)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:134)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:964)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:904)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:896)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)

我缺少什么?

最佳答案

试试下面的配置-

appender.async.type = Async
appender.async.name = asyncAppender
appender.async.appenderRef.type = AppenderRef
appender.async.appenderRef.ref = consoleAppender

关于java - 无法将 Log4j2 AsyncAppender 与 log4j2.properties 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56802488/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com