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 somethin
It would have been nice to control logging using only logging.properties:
org = FINE
com = SEVERE
Unfortunately, the corresponding log must have actually been created. Changing your conf file won't do that work for you. Add the loggers yourself and it will work:
private static final Logger ORG_ROOT_LOGGER = Logger.getLogger("org");
private static final Logger COM_ROOT_LOGGER = Logger.getLogger("com");
Nested loggers in your application work the same way:
# perhaps in the main entry point for your application?
private static final Logger APP_ROOT_LOGGER = Logger.getLogger("com.myapp");
# in each package or class you want to have separately controlled loggers
private static final Logger LOG = Logger.getLogger(HelloWorldApp.class.getName());
# in logging.properties
com.myapp.level = FINE # sufficient to make all your loggers log as FINE
com.myapp.HelloWorldApp.level = SEVERE # turn off msgs from that particularly chatty app