I have defined log4j2.properties as
    ...
    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
Exception during runtime:
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)
What is that I'm missing?
Log4j 2 doesn't support the Log4j v1 ". properties" format anymore (yet, since v2. 4, Log4j supports a Property format, but its syntax is totally different from v1 format). New formats are XML, JSON, and YAML, see the documentation (note: if you used one of these formats in a file called ".
We should put log4j2. properties anywhere in the application's classpath. Log4j2 will scan all classpath locations to find out this file and then load it. We have put the file in resources folder.
Log4j2 ConsoleAppender ConfigurationThe target poperty specifies the target of the logging messages i.e. SYSTEM_OUT or SYSTEM_ERR . The follow attribute tells whether the appender should honor the reassignments of System. out or System. err made after the logging configuration has been initialized.
Try below configuration -
appender.async.type = Async
appender.async.name = asyncAppender
appender.async.appenderRef.type = AppenderRef
appender.async.appenderRef.ref = consoleAppender
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With