java - Checking whether there is a logger set to DEBUG in Log4J -


I have a code that is called multiple times which also calls the logger. The debug enabled () cost is too high I can store the isDebugEnabled () value in a constant variable on the class, but then I can loosen the option to enable debug while running the server.
All of my calls on Log4J are now done by custom wrappers.
One solution I want to implement is that if a logger is not set to debug, then I will be able to return ASAP by checking some global boolean variables and only if calling one or more loggers to call the rapper The call will be forwarded to Log4J.

Is there a way to ask Log4J configuration if there are one or more loggers set to debug? In this way, I can see it every 5 seconds and will turn a global bullion on / off which will be used by my rapper.

If you are having problems working with log-in then I would advise you.

If you need to stick with the log-in then you can do one of the following. The following code will check the logging level of the root logger. This is all you need.

  level level = logmanager .getRootLogger (). GetLevel (); If (level == Level.DEBUG) System.out.println ("DEBUG");  

In the event that you really want to check every logger, you can do this.

 for  (counting> logger> en = log manager.strust loggers (); En.hasMoreElements ();) System.out.println (en.nextElement (). IsDebugEnabled ());  

For completion, you can change the root logging level with the following.

  LogManager.getRootLogger (). SetLevel (Level.DEBUG);  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -