title: Java - dynamically change logging level
body: <p>I would like to be able to tell the JVM to stop logging certain level of messages at some point in the execution chain. At some point I want to only log messages with <code>SEVERE</code> level, so I was thinking of doing this:</p>
  
  <pre><code>    for(Enumeration&lt;String&gt; loggerNames = logManager.getLoggerNames(); loggerNames.hasMoreElements();){
          String name = loggerNames.nextElement();
          Logger nextLogger = logManager.getLogger(name);
          if(nextLogger != null)
              nextLogger.setLevel(Level.SEVERE);
      }
  </code></pre>
  
  <p>Is there a cleaner way to achieve the same logic i.e. set a global variable that would stop printing to log unless SEVERE? I need to distinguish between Console output (in test) and file output in live, so I could potentially set these level on the handler (console and File)?</p>