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
Post a Comment