2

I am using java.util.logging.Logger and I want to enable all log levels. I thought the following would work:

logger.setLevel(Level.ALL);

But apparently it doesn't. Only INFO level logging statements are taking effect, and others are being swallowed.

How do I enable all log levels?

missingfaktor
  • 90,905
  • 62
  • 285
  • 365
  • I had similar experience with android native logging and got no answer so far. See http://stackoverflow.com/questions/9468444/bug-in-android-util-log-or-in-my-sample-code-thinking – k3b Jun 04 '12 at 14:34
  • @k3b, that's surprising. I hope at least answer to this problem is known. – missingfaktor Jun 04 '12 at 14:46

1 Answers1

3

It's probably the log handler that is swallowing the log records. You need to set the log level on your handlers too. For example:

for (Handler handler : Logger.getLogger("").getHandlers()) {
  handler.setLevel(Level.ALL);
}

Or you can read your configuration from a logging.properties file (just put it in your CLASSPATH root), or you can read a logging.properties-style configuration from a stream using LogManager.getLogManager().readConfiguration(someInputStream).

sjr
  • 9,769
  • 1
  • 25
  • 36