Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 3
    This didn't affect my logger at all. I used setLevel(logger, Level.ERROR); and logger.debug statements still printed. My log4j2.xml file is at pastebin.com/fcbV2mTW Commented Aug 19, 2015 at 1:09
  • I updated the code. Let me know if there are any issues with it. Commented Sep 6, 2016 at 21:18
  • 4
    In log4j 2.7 LoggerContext hasn't a getConfiguration() method, see logging.apache.org/log4j/2.x/log4j-api/apidocs/index.html?org/… Commented Nov 23, 2016 at 13:53
  • log4j-core-2.7.jar has and can be used as final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); final Configuration configuration = ctx.getConfiguration(); Commented Aug 28, 2017 at 16:40
  • 10
    After seeing this, I am thinking.. "Maybe they do not want us to change the level in runtime?" Commented Oct 23, 2017 at 19:04