Class NameWrappingLogger
- java.lang.Object
-
- java.util.logging.Logger
-
- de.aristaflow.adept2.util.logging.WrappingLogger
-
- de.aristaflow.adept2.util.logging.NameWrappingLogger
-
public class NameWrappingLogger extends WrappingLogger
A wrapping logger that uses the name filters registered for any handlers of a wrapped logger and its parent loggers and uses these filters when determiningisLoggable(Level)
. Additionally, if the filter has a less severe level than the logger, this wrapping logger simulates the level of the filter so that the corresponding messages will be logged.
-
-
Field Summary
Fields Modifier and Type Field Description protected NameFilter[]
filters
The name filters of the (parent) handlers of the wrapped logger ornull
in case there is no name filter.-
Fields inherited from class de.aristaflow.adept2.util.logging.WrappingLogger
innerLogger
-
Fields inherited from class java.util.logging.Logger
global, GLOBAL_LOGGER_NAME
-
-
Constructor Summary
Constructors Constructor Description NameWrappingLogger(String loggerName, Logger innerLogger, String filterName)
Creates a logger specific for the designated names.NameWrappingLogger(Logger innerLogger, String filterName)
Creates a logger similar to the designated one except that the filter name is used to check for loggable in case a corresponding name filter is registered for any of the (parent) handlers of the logger.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isLoggable(Level level)
Since this method delegates to the inner logger, it usually has to be overridden in case (a subclass of) this logger sets the level without propagating it to the wrapped logger.void
setLevel(Level newLevel)
-
Methods inherited from class de.aristaflow.adept2.util.logging.WrappingLogger
addHandler, equals, getFilter, getHandlers, getLevel, getName, getParent, getResourceBundle, getResourceBundleName, getUseParentHandlers, hashCode, log, removeHandler, setFilter, setLevel, setParent, setUseParentHandlers
-
Methods inherited from class java.util.logging.Logger
config, config, entering, entering, entering, exiting, exiting, fine, fine, finer, finer, finest, finest, getAnonymousLogger, getAnonymousLogger, getGlobal, getLogger, getLogger, info, info, log, log, log, log, log, log, logp, logp, logp, logp, logp, logp, logrb, logrb, logrb, logrb, logrb, logrb, logrb, logrb, setResourceBundle, severe, severe, throwing, warning, warning
-
-
-
-
Field Detail
-
filters
protected NameFilter[] filters
The name filters of the (parent) handlers of the wrapped logger ornull
in case there is no name filter.
-
-
Constructor Detail
-
NameWrappingLogger
public NameWrappingLogger(Logger innerLogger, String filterName)
Creates a logger similar to the designated one except that the filter name is used to check for loggable in case a corresponding name filter is registered for any of the (parent) handlers of the logger. The name of this logger will be the same as that of the designated logger.
Note that changing the filters or the handlers afterwards will propagate to this logger so the loggable will reflect the behaviour at construction time.- Parameters:
innerLogger
- The wrapped logger.filterName
- The name which to check for loggable.
-
NameWrappingLogger
public NameWrappingLogger(String loggerName, Logger innerLogger, String filterName)
Creates a logger specific for the designated names. The filter name is used to check for loggable in case a corresponding name filter is registered for any of the (parent) handlers of the logger. The logger name will be the name of this logger. This may be the same as the name of the designated logger.
Note that changing the filters or the handlers afterwards will propagate to this logger so the loggable will reflect the behaviour at construction time.- Parameters:
loggerName
- The name of the wrapping logger. This may be the same as the name of the designated wrapped logger.innerLogger
- The wrapped logger.filterName
- The name which to check for loggable.
-
-
Method Detail
-
setLevel
public void setLevel(Level newLevel) throws SecurityException
- Overrides:
setLevel
in classWrappingLogger
- Throws:
SecurityException
-
isLoggable
public boolean isLoggable(Level level)
Description copied from class:WrappingLogger
Since this method delegates to the inner logger, it usually has to be overridden in case (a subclass of) this logger sets the level without propagating it to the wrapped logger.- Overrides:
isLoggable
in classWrappingLogger
-
-