log4j2 - Log4j version 2 set root logging level from Java? -


in log4j version 2, how 1 accomplish previous versions of log4j did when called java code thus:

logger.getrootlogger().setlevel( level.trace ); 

i want, depending on utility's command-line option, turn on tracing.

try this

loggercontext ctx = (loggercontext) logmanager.getcontext(false); configuration config = ctx.getconfiguration(); loggerconfig loggerconfig = config.getloggerconfig(logmanager.root_logger_name);  loggerconfig.setlevel(level); ctx.updateloggers();   

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -