missingfaktor
missingfaktor

Reputation: 92056

java.util.logging.Logger swallowing logs

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?

Upvotes: 2

Views: 310

Answers (1)

sjr
sjr

Reputation: 9885

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).

Upvotes: 3

Related Questions