Re: AddAppender programmatically in a proper way

2022-10-21 Thread Volkan Yazıcı
The snippet you shared tries to add your custom appender to an already initialized logger context. Do you really need to add your appender after initialization and programmatically? If not, you can simply use your appender in `log4j2.xml` given you have its class in a package scanned by Log4j. You

AddAppender programmatically in a proper way

2022-10-21 Thread Thomas Hartwig
I want to add a customized Appender to Log4J 2.x. However there is no clear API to use it. Right now I am using: ((org.apache.logging.log4j.core.Logger)LogManager.getRootLogger()).addAppender(new MyAppender()); This is working, however the API states this: This method is not exposed through