We have unit tests that do this. Basically you need to do:

final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
Map<String, LoggerConfig> loggers = config.getLoggers();
for (Map.Entry<String, LoggerConfig> logger : loggers.entrySet()) {
     logger.setLevel(Level.DEBUG);
}
ctx.updateLoggers();

If you only want to update the root logger than do:

LoggerConfig rootLogger = config.getRootLogger();
rootLogger.setLevel(Level.DEBUG);

instead of the for loop.

Ralph


> On Nov 9, 2015, at 6:53 PM, John Lussmyer <[email protected]> wrote:
> 
> I'm hoping there is an easy to to just change the root level of my logger 
> configuration on the fly.
> I want to be able to provide a configuration option to my users to turn up 
> the logging level.
> I don't want to reconfigure everything, just change the level.
> 
> Is there any easy way to do that?  Or do I have to build a Configuration 
> factory?
> 
> 
> ________________________________
> Confidentiality notice: This message may contain confidential information. It 
> is intended only for the person to whom it is addressed. If you are not that 
> person, you should not use this message. We request that you notify us by 
> replying to this message, and then delete all copies including any contained 
> in your reply. Thank you.

Reply via email to