[
https://issues.apache.org/jira/browse/LOG4J2-544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13916641#comment-13916641
]
Ralph Goers commented on LOG4J2-544:
------------------------------------
{code}
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
Map<String, LoggerConfig> loggers = config.getLoggers();
Map<String, Level> priorLevel = new HashMap<String, Level>():
for (Map.Entry<String, LoggerConfig> entry : loggers.entrySet()) {
priorLevel.put(entry.getKey(), entry.getValue().getLevel());
entry.getValue().setLevel(newLevel):
}
ctx.updateLoggers();
{code}
> Change root logger level and spread to every logger with the same logconfig
> at runtime
> --------------------------------------------------------------------------------------
>
> Key: LOG4J2-544
> URL: https://issues.apache.org/jira/browse/LOG4J2-544
> Project: Log4j 2
> Issue Type: Question
> Components: API, Core
> Affects Versions: 2.0-rc1
> Environment: win 7 64x
> java 1.7
> Reporter: Hongdi Ren
>
> Hi everyone,
> There's a need to increase the log level for EVERY logger at runtime and
> after certain processing, bring it back to the original level.
> I've tried to set the level of ROOT logger use log4j.core.Logger.setLevel,
> but the level only works on the root logger. I've done some investigation and
> find setLevel doesn't change the LoggerConfig object, just change the level
> related to current logger, so loggers share the same LoggerConfig won't
> change the logger level.
> Is there any way to meet my requirement? I think this is a common one when we
> have batch work in the application.
> Thanks in advance!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]