Programmatically change log level in Log4j2

The Easy Way : EDITED according to log4j2 version 2.4 FAQ You can set a logger’s level with the class Configurator from Log4j Core. BUT be aware that the Configurator class is not part of the public API. // org.apache.logging.log4j.core.config.Configurator; Configurator.setLevel(“com.example.Foo”, Level.DEBUG); // You can also set the root logger: Configurator.setRootLevel(Level.DEBUG); Source The Preferable Way … Read more

How to Create a Custom Appender in log4j2?

This works quite differently in log4j2 than in log4j-1.2. In log4j2, you would create a plugin for this. The manual has an explanation with an example for a custom appender here: http://logging.apache.org/log4j/2.x/manual/extending.html#Appenders It may be convenient to extend org.apache.logging.log4j.core.appender.AbstractAppender, but this is not required. When you annotate your custom Appender class with @Plugin(name=”MyCustomAppender”, …., the … Read more