The Configurator class provides several methods to change levels in Log4j. An important feature to understand before using these APIs is that logger names are hierarchical, see Refining Logging with Hierarchical Loggers.
The Configurator.setAllLevels(String, Level) method sets the level of the given named logger and all child loggers. Recall that in Log4j, loggers are hierachical. If you have the loggers
com.foo.c, and you call
setAllLevels("com.foo", Level.DEBUG) then all the loggers I listed will be set to
DEBUG as will
"com.foo". A logger
"com.bar" will remain as is.
Map&lt;String, Level&gt; map = new HashMap&lt;&gt;(); map.put("com.foo", Level.DEBUG); map.put("com.bar", Level.DEBUG); Configurator.setLevel(map);
This will set the loggers
DEBUG but no existing child loggers of either will be affected. If you create a new child logger though, that child logger will inherit its level from its parent.
Finally, Configurator.setRootLevel(Level) sets the level of the root logger to the given level without affecting child loggers. The root logger is the topmost logger with a name of
"" (the empty string).