1

I'm trying the following code example (based on code from here). My aim is to set the level of the logging from run time.

package logchecker;
import java.util.logging.*;

public class Logchecker {

    private static final Logger logger = Logger.getLogger(Logchecker.class.getName());

   public static void main(String[] args) {
      System.out.println("This logger's level is " + logger.getLevel());   // null
      logger.setLevel(Level.ALL);
      System.out.println("This logger's level is " + logger.getLevel());   // null
      logger.info("TEST");
      logger.finest("FINEST TEST");
   }
}

The output is:

This logger's level is null

This logger's level is ALL

Sep 17, 2013 1:46:31 PM logchecker.Logchecker main

INFO: TEST

It obviously doesn't output the log.finest. What am I missing? I'm running with NetBeans 7.3.

Community
  • 1
  • 1
Dror Cohen
  • 6,731
  • 5
  • 29
  • 32
  • 1
    Maybe [this](http://stackoverflow.com/questions/6315699/why-are-my-level-fine-logging-messages-not-showing) question on SO can help you. – Stefan Sep 17 '13 at 12:16
  • 1
    This is probably a duplicate of http://stackoverflow.com/questions/6315699/why-are-my-level-fine-logging-messages-not-showing?rq=1 – Qben Sep 17 '13 at 12:17

1 Answers1

1

I needed to set my Handlers level as well. Added the following code to my main:

Logger root = Logger.getLogger("");
Handler[] handlers = root.getHandlers();
for(Handler h: handlers){
    h.setLevel(Level.INFO);
}

Of course you can set the level to whatever you need.

thanks again to the comments for directing me to the solution

Dror Cohen
  • 6,731
  • 5
  • 29
  • 32