public class LogUtils extends java.lang.Object
|Modifier and Type||Method and Description|
Returns the logger for a given name, retaining a reference to that logger.
public static java.util.logging.Logger getLogger(java.lang.String name)
The output is the same as
for which it is a drop-in replacement,
but because a reference is retained by this class,
the returned object will not be subsequently garbage collected;
as noted in the
"It is important to note that the Logger returned by one of the
getLoggerfactory methods may be garbage collected at any time if a strong reference to the Logger is not kept."
So if you want to modify one of the loggers in the logging hierarchy, you can do it like:
LogUtils.getLogger("a.b.c").setLevel(Level.WARNING)If you make the corresponding call using
Logger.getLogger, the logger may have been garbage collected and recreated without the desired configuration by the time it's actually used to log something.
name- logger name