log4j2

Programmatically change log level in Log4j2

故事扮演 提交于 2019-11-26 08:01:02
问题 I\'m interested in programmatically changing the log level in Log4j2. I tried looking at their configuration documentation but that didn\'t seem to have anything. I also tried looking in the package: org.apache.logging.log4j.core.config , but nothing in there looked helpful either. 回答1: 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

Is it worth to use slf4j with log4j2

坚强是说给别人听的谎言 提交于 2019-11-26 06:59:28
问题 I am not able to decide whether to use slf4j or not with log4j2. Based on online posts, does not look like it will have any performance hit but is it really required. Also these points rule in favor of log4j2: SLF4J forces your application to log Strings. The Log4j 2 API supports logging any CharSequence if you want to log text, but also supports logging any Object as is. The Log4j 2 API offers support for logging Message objects, Java 8 lambda expressions and garbage-free logging (it avoids