I have a java program using an external library. The main program uses log4j
to log its messages and the library uses java.util.logging
.
My problem is that log messages from the external library and the main program are mixed in the console.
I would like to redirect all log messages from the external library to a file. I tried to do that with a logging.properties
file:
handlers= java.util.logging.FileHandler
.level= INFO
java.util.logging.FileHandler.pattern = foo.log
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
This file is initialized with:
System.setProperty("java.util.logging.config.file", "logging.properties");
Unfortunately, log messages from the external library keep appearing in the console.
Should I use something like slf4j
to intercept log messages from java.util.logging
?
Thank you for your time.