Class ExtendedLogger
java.lang.Object
java.util.logging.Logger
com.clumd.projects.java_custom_logging.logging.ExtendedLogger
- Direct Known Subclasses:
ExtendedSlf4jLogger
This class is a very basic extension of the built-in JUL
Logger, but with an expansive selection of 'log'
methods for all the combinations of operations the average user might require.
There is also support for the 'tags' paradigm for log messages, explained as part of ExtendedLogRecord
documentation. Other than the method signatures, basically the rest is a pass-through to the underling Logger, but
using the aforementioned Extended Log Record in place of basic Log Record.
-
Field Summary
Fields inherited from class java.util.logging.Logger
global, GLOBAL_LOGGER_NAME -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedExtendedLogger(String name) Protected method to construct a logger for a named subsystem.protectedExtendedLogger(String name, Set<String> bakedInTags) Protected method to construct a logger for a named subsystem. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidwithControllersWhichShouldIgnore(Set<Class<? extends StreamHandler>> controllersIgnoringThisLogger) Protected method to construct a logger for a named subsystem.Methods inherited from class java.util.logging.Logger
addHandler, config, config, entering, entering, entering, exiting, exiting, fine, fine, finer, finer, finest, finest, getAnonymousLogger, getAnonymousLogger, getFilter, getGlobal, getHandlers, getLevel, getLogger, getLogger, getName, getParent, getResourceBundle, getResourceBundleName, getUseParentHandlers, info, info, isLoggable, log, log, logp, logp, logp, logp, logp, logp, logrb, logrb, logrb, logrb, logrb, logrb, logrb, logrb, removeHandler, setFilter, setLevel, setParent, setResourceBundle, setUseParentHandlers, severe, severe, throwing, warning, warning
-
Constructor Details
-
ExtendedLogger
Protected method to construct a logger for a named subsystem.The logger will be initially configured with a null Level and with useParentHandlers set to true.
- Parameters:
name- A name for the logger. This should be a dot-separated name and should normally be based on the package name or class name of the subsystem, such as java.net or javax.swing. It may be null for anonymous Loggers.- Throws:
MissingResourceException- if the resourceBundleName is non-null and no corresponding resource can be found.
-
ExtendedLogger
Protected method to construct a logger for a named subsystem.The logger will be initially configured with a null Level and with useParentHandlers set to true.
- Parameters:
name- A name for the logger. This should be a dot-separated name and should normally be based on the package name or class name of the subsystem, such as java.net or javax.swing. It may be null for anonymous Loggers.bakedInTags- A collection of tags which should be applied to every single log message that this Logger will generate. This is mostly for uses such as distributed computing trace IDs or things such as concrete / unchanging environment variables.
-
-
Method Details
-
withControllersWhichShouldIgnore
public ExtendedLogger withControllersWhichShouldIgnore(Set<Class<? extends StreamHandler>> controllersIgnoringThisLogger) Protected method to construct a logger for a named subsystem.The logger will be initially configured with a null Level and with useParentHandlers set to true.
- Parameters:
controllersIgnoringThisLogger- A collection ofLog Controllers(Which must extend aStreamHandler), which in an ideal implementation will IGNORE all log messages from this logger. This is because by default, all log messages will be published to ALL handlers across our JUL implementation. If you had particular logs (idk, say something silly like passwords) which you WANT to log to 'temporary' console-out, but never to a permanent file-out Log Handler, then you could pass FileController classes into this method, and a well-respecting java-common-utils compatible log controller should ignore messages this Logger will pass through.- Returns:
- This logger, after having applied these properties. This is to allow for nice method chaining when constructing this logger. Such as LogRoot.createLogger(name, bakedTags).withControllersWhichShouldIgnore(Set.of(FileController.class));
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-
log
-