GitHub user ppkarwasz added a comment to the discussion: Help with migrating 
from log4j to log4j2 (we also use a slf4j -> log4j)

> If I do:
> 
> ```java
> if (name == null) {
>   org.apache.logging.log4j.core.config.Configurator.setAllLevels("", 
> newLevel);
> } else {
>   LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
>   //org.apache.logging.log4j.core.config.Configuration config = 
> ctx.getConfiguration();
>   ctx.getLoggerRegistry()
>       .getLoggers()
>       .forEach(
>          logger -> {
>            String loggerName = logger.getName();
>            if (loggerName.contains(name)) {
>              
> org.apache.logging.log4j.core.config.Configurator.setLevel(loggerName, 
> newLevel);
>            }
>          });
> }
> ```
> 
> that works. Or do you recommend something else?

`Configurator.setAllLevels` should work with any logger name, not just "". Are 
you saying it doesn’t behave that way in your case?


GitHub link: 
https://github.com/apache/logging-log4j2/discussions/3914#discussioncomment-14310860

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to