How to make logging.properties and commons-logging.properties property files working?

Damian picture Damian · Feb 10, 2011 · Viewed 15.8k times · Source

I have two property files in my default package (I'm using NetBeans):

commons-logging.properties with property:

org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger

and logging.properties with:

handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=SEVERE

java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter

I'm getting INFO level messages in output. What i'm doing wrong? I also haven't found any information about JDK configuration, just example as above.

Answer

Peter Jamieson picture Peter Jamieson · Sep 22, 2011

How are you calling the java?

Are you putting -Djava.util.logging.config.file=/logging.properties in your java command?

If not, it would ignore your logging.properties and log everything.

.level=ALL on a line of it's own is used as a global level, e.g. : -

handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=INFO
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
.level=SEVERE
mypackage.level=INFO

would only log INFO messages from mypackage and SEVERE from everything else.