Looking for log4j.appender.console.target
equivalent in java.util.logging
framework in config properties file (not using code).
I have more than a thousand Java classes. Almost all of them have their own Logger instance something like:
import java.util.logging.Logger;
Logger logger = Logger.getLogger(MyClass.class.getName());
My problem here is, logger prints all the log messages to System.err
stream. But, I want it to be printed on System.out
.
I know that I can add handler like below to use a different stream.
logger.addHandler(new StreamHandler(System.out, new SimpleFormatter()))
But I have quite a few Java classes to be changed. which I don't want to do.
How can I make java.uitl.logging
framework to print log messages to System.out
stream for all the classes?
I'm looking for a configuration setting in properties file which is same for all the classes.
Like in case of log4j, we have log4j.properties
file where I can set the log4j.appender.console.target=System.out
, which tells all the log4j loggers to print log messages to System.out
. I want same thing to be done with java.util.logging
framework as well.