In the java.util.logging
logging framework there's a special Logger
instance named "global"
, but I can't find any documentation of what its intended use is. The documentation for Logger.getGlobal()
just says
Return global logger object with the name
Logger.GLOBAL_LOGGER_NAME
.
Logger.GLOBAL_LOGGER_NAME
, in turn, is documented only as
GLOBAL_LOGGER_NAME
is a name for the global logger.
My fairly extensive searches didn't turn up any more useful documentation.
What is the global logger intended to be used for? Is that documented somewhere that I missed?
The "global" Logger object is provided as a convenience to developers who are making casual use of the Logging package. Developers who are making serious use of the logging package (for example in products) should create and use their own Logger objects, with appropriate names, so that logging can be controlled on a suitable per-Logger granularity. Developers also need to keep a strong reference to their Logger objects to prevent them from being garbage collected.
From here (don't look at the fact that the field is deprecated, I just wanted to point you to a valid explanation).
Normally, when enabling logging in an application, you define more granular loggers, usually per Java packages or classes.
If you do not want to do that, you can use this global logger, which will handle all logging statements, no matter the library, package or class they are contained in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With