java.util.logging: how to set level by logger package (or prefix)?

Igor Gatis picture Igor Gatis · Oct 13, 2010 · Viewed 18.5k times · Source

My app uses many libraries and I'm using java.util.logging for logging. I'd like to be able to set different logging levels for each library by doing something like:

org.datanucleus.*.level = WARNING
com.google.apphosting.*.level = WARNING
com.myapp.*.level = FINE

Is is possible?

Answer

VolkanT picture VolkanT · Jan 17, 2014

You shouldn't use "*". A sample logging.properties could be such as:

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

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

org.datanucleus.level=WARNING
org.datanucleus.handler=java.util.logging.ConsoleHandler

com.myapp.level=FINE
com.myapp.handler=java.util.logging.ConsoleHandler

And if all "org" level should be logged as WARNING then

org.level=WARNING
org.handler=java.util.logging.ConsoleHandler