Package ch.qos.logback.classic
Class Logger
java.lang.Object
ch.qos.logback.classic.Logger
- All Implemented Interfaces:
AppenderAttachable<ILoggingEvent>,Serializable,org.slf4j.Logger,org.slf4j.spi.LocationAwareLogger
public final class Logger
extends Object
implements org.slf4j.Logger, org.slf4j.spi.LocationAwareLogger, AppenderAttachable<ILoggingEvent>, Serializable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AppenderAttachableImpl<ILoggingEvent> It is assumed that once the 'aai' variable is set to a non-null value, it will never be reset to null.private booleanAdditivity is set to true by default, that is children inherit the appenders of their ancestors by default.The children of this logger.private intstatic final StringThe fully qualified name of this class.private Level(package private) final LoggerContextprivate StringThe name of this loggerprivate LoggerThe parent of this category.private static final longFields inherited from interface org.slf4j.spi.LocationAwareLogger
DEBUG_INT, ERROR_INT, INFO_INT, TRACE_INT, WARN_INTFields inherited from interface org.slf4j.Logger
ROOT_LOGGER_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAppender(Appender<ILoggingEvent> newAppender) Add an appender.private intprivate voidbuildLoggingEventAndAppend(String localFQCN, org.slf4j.Marker marker, Level level, String msg, Object[] params, Throwable t) voidcallAppenders(ILoggingEvent event) Invoke all the appenders of this logger.private FilterReplycallTurboFilters(org.slf4j.Marker marker, Level level) Method that calls the attached TurboFilter objects based on the logger and the level.(package private) LoggercreateChildByLastNamePart(String lastPart) Create a child of this logger by suffix, that is, the part of the name extending this logger.(package private) LoggercreateChildByName(String childName) The default size of child list arrays.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidRemove all previously added appenders from this logger instance.booleandetachAppender(Appender<ILoggingEvent> appender) Remove the appender passed as parameter form the list of appenders.booleandetachAppender(String name) Detach the appender with the name passed as parameter from the list of appenders.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidprivate voidfilterAndLog_0_Or3Plus(String localFQCN, org.slf4j.Marker marker, Level level, String msg, Object[] params, Throwable t) The next methods are not merged into one because of the time we gain by not creating a new Object[] with the params.private voidfilterAndLog_1(String localFQCN, org.slf4j.Marker marker, Level level, String msg, Object param, Throwable t) private voidfilterAndLog_2(String localFQCN, org.slf4j.Marker marker, Level level, String msg, Object param1, Object param2, Throwable t) getAppender(String name) Get an appender by name.(package private) LoggergetChildByName(String childName) (package private) intgetLevel()Return the context for this logger.getName()private voidhandleParentLevelChange(int newParentLevelInt) This method is invoked by parent logger to let this logger know that the prent's levelInt changed.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidbooleanbooleanisAttached(Appender<ILoggingEvent> appender) Returnstrueif the specified appender is in list of attached attached,falseotherwise.booleanbooleanisDebugEnabled(org.slf4j.Marker marker) booleanisEnabledFor(Level level) booleanisEnabledFor(org.slf4j.Marker marker, Level level) booleanbooleanisErrorEnabled(org.slf4j.Marker marker) booleanbooleanisInfoEnabled(org.slf4j.Marker marker) private booleanbooleanbooleanisTraceEnabled(org.slf4j.Marker marker) booleanbooleanisWarnEnabled(org.slf4j.Marker marker) Get an iterator for appenders contained in the parent object.private voidvoidlog(org.slf4j.event.LoggingEvent slf4jEvent) Support SLF4J interception during initialization as introduced in SLF4J version 1.7.15voidlog(org.slf4j.Marker marker, String fqcn, int levelInt, String message, Object[] argArray, Throwable t) protected ObjectAfter serialization, the logger instance does not know its LoggerContext.(package private) voidvoidsetAdditive(boolean additive) voidtoString()voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoid
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
FQCN
The fully qualified name of this class. Used in gathering caller information. -
name
The name of this logger -
level
-
effectiveLevelInt
private transient int effectiveLevelInt -
parent
The parent of this category. All categories have at least one ancestor which is the root category. -
childrenList
The children of this logger. A logger may have zero or more children. -
aai
It is assumed that once the 'aai' variable is set to a non-null value, it will never be reset to null. it is further assumed that only place where the 'aai'ariable is set is within the addAppender method. This method is synchronized on 'this' (Logger) protecting against simultaneous re-configuration of this logger (a very unlikely scenario).It is further assumed that the AppenderAttachableImpl is responsible for its internal synchronization and thread safety. Thus, we can get away with *not* synchronizing on the 'aai' (check null/ read) because
1) the 'aai' variable is immutable once set to non-null
2) 'aai' is getAndSet only within addAppender which is synchronized
3) all the other methods check whether 'aai' is null
4) AppenderAttachableImpl is thread safe
-
additive
private transient boolean additiveAdditivity is set to true by default, that is children inherit the appenders of their ancestors by default. If this variable is set tofalsethen the appenders located in the ancestors of this logger will not be used. However, the children of this logger will inherit its appenders, unless the children have their additivity flag set tofalsetoo. See the user manual for more details. -
loggerContext
-
-
Constructor Details
-
Logger
Logger(String name, Logger parent, LoggerContext loggerContext)
-
-
Method Details
-
getEffectiveLevel
-
getEffectiveLevelInt
int getEffectiveLevelInt() -
getLevel
-
getName
- Specified by:
getNamein interfaceorg.slf4j.Logger
-
isRootLogger
private boolean isRootLogger() -
getChildByName
-
setLevel
-
handleParentLevelChange
private void handleParentLevelChange(int newParentLevelInt) This method is invoked by parent logger to let this logger know that the prent's levelInt changed.- Parameters:
newParentLevelInt-
-
detachAndStopAllAppenders
public void detachAndStopAllAppenders()Remove all previously added appenders from this logger instance. This is useful when re-reading configuration information.- Specified by:
detachAndStopAllAppendersin interfaceAppenderAttachable<ILoggingEvent>
-
detachAppender
Description copied from interface:AppenderAttachableDetach the appender with the name passed as parameter from the list of appenders.- Specified by:
detachAppenderin interfaceAppenderAttachable<ILoggingEvent>
-
addAppender
Description copied from interface:AppenderAttachableAdd an appender.- Specified by:
addAppenderin interfaceAppenderAttachable<ILoggingEvent>
-
isAttached
Description copied from interface:AppenderAttachableReturnstrueif the specified appender is in list of attached attached,falseotherwise.- Specified by:
isAttachedin interfaceAppenderAttachable<ILoggingEvent>
-
iteratorForAppenders
Description copied from interface:AppenderAttachableGet an iterator for appenders contained in the parent object.- Specified by:
iteratorForAppendersin interfaceAppenderAttachable<ILoggingEvent>
-
getAppender
Description copied from interface:AppenderAttachableGet an appender by name.- Specified by:
getAppenderin interfaceAppenderAttachable<ILoggingEvent>
-
callAppenders
Invoke all the appenders of this logger.- Parameters:
event- The event to log
-
appendLoopOnAppenders
-
detachAppender
Remove the appender passed as parameter form the list of appenders.- Specified by:
detachAppenderin interfaceAppenderAttachable<ILoggingEvent>
-
createChildByLastNamePart
Create a child of this logger by suffix, that is, the part of the name extending this logger. For example, if this logger is named "x.y" and the lastPart is "z", then the created child logger will be named "x.y.z".IMPORTANT: Calls to this method must be within a synchronized block on this logger.
- Parameters:
lastPart- the suffix (i.e. last part) of the child logger name. This parameter may not include dots, i.e. the logger separator character.- Returns:
-
localLevelReset
private void localLevelReset() -
recursiveReset
void recursiveReset() -
createChildByName
The default size of child list arrays. The JDK 1.5 default is 10. We use a smaller value to save a little space. -
filterAndLog_0_Or3Plus
private void filterAndLog_0_Or3Plus(String localFQCN, org.slf4j.Marker marker, Level level, String msg, Object[] params, Throwable t) The next methods are not merged into one because of the time we gain by not creating a new Object[] with the params. This reduces the cost of not logging by about 20 nanoseconds. -
filterAndLog_1
-
filterAndLog_2
-
buildLoggingEventAndAppend
-
trace
- Specified by:
tracein interfaceorg.slf4j.Logger
-
trace
- Specified by:
tracein interfaceorg.slf4j.Logger
-
trace
- Specified by:
tracein interfaceorg.slf4j.Logger
-
trace
- Specified by:
tracein interfaceorg.slf4j.Logger
-
trace
- Specified by:
tracein interfaceorg.slf4j.Logger
-
trace
- Specified by:
tracein interfaceorg.slf4j.Logger
-
trace
- Specified by:
tracein interfaceorg.slf4j.Logger
-
trace
- Specified by:
tracein interfaceorg.slf4j.Logger
-
trace
- Specified by:
tracein interfaceorg.slf4j.Logger
-
trace
- Specified by:
tracein interfaceorg.slf4j.Logger
-
isDebugEnabled
public boolean isDebugEnabled()- Specified by:
isDebugEnabledin interfaceorg.slf4j.Logger
-
isDebugEnabled
public boolean isDebugEnabled(org.slf4j.Marker marker) - Specified by:
isDebugEnabledin interfaceorg.slf4j.Logger
-
debug
- Specified by:
debugin interfaceorg.slf4j.Logger
-
debug
- Specified by:
debugin interfaceorg.slf4j.Logger
-
debug
- Specified by:
debugin interfaceorg.slf4j.Logger
-
debug
- Specified by:
debugin interfaceorg.slf4j.Logger
-
debug
- Specified by:
debugin interfaceorg.slf4j.Logger
-
debug
- Specified by:
debugin interfaceorg.slf4j.Logger
-
debug
- Specified by:
debugin interfaceorg.slf4j.Logger
-
debug
- Specified by:
debugin interfaceorg.slf4j.Logger
-
debug
- Specified by:
debugin interfaceorg.slf4j.Logger
-
debug
- Specified by:
debugin interfaceorg.slf4j.Logger
-
error
- Specified by:
errorin interfaceorg.slf4j.Logger
-
error
- Specified by:
errorin interfaceorg.slf4j.Logger
-
error
- Specified by:
errorin interfaceorg.slf4j.Logger
-
error
- Specified by:
errorin interfaceorg.slf4j.Logger
-
error
- Specified by:
errorin interfaceorg.slf4j.Logger
-
error
- Specified by:
errorin interfaceorg.slf4j.Logger
-
error
- Specified by:
errorin interfaceorg.slf4j.Logger
-
error
- Specified by:
errorin interfaceorg.slf4j.Logger
-
error
- Specified by:
errorin interfaceorg.slf4j.Logger
-
error
- Specified by:
errorin interfaceorg.slf4j.Logger
-
isInfoEnabled
public boolean isInfoEnabled()- Specified by:
isInfoEnabledin interfaceorg.slf4j.Logger
-
isInfoEnabled
public boolean isInfoEnabled(org.slf4j.Marker marker) - Specified by:
isInfoEnabledin interfaceorg.slf4j.Logger
-
info
- Specified by:
infoin interfaceorg.slf4j.Logger
-
info
- Specified by:
infoin interfaceorg.slf4j.Logger
-
info
- Specified by:
infoin interfaceorg.slf4j.Logger
-
info
- Specified by:
infoin interfaceorg.slf4j.Logger
-
info
- Specified by:
infoin interfaceorg.slf4j.Logger
-
info
- Specified by:
infoin interfaceorg.slf4j.Logger
-
info
- Specified by:
infoin interfaceorg.slf4j.Logger
-
info
- Specified by:
infoin interfaceorg.slf4j.Logger
-
info
- Specified by:
infoin interfaceorg.slf4j.Logger
-
info
- Specified by:
infoin interfaceorg.slf4j.Logger
-
isTraceEnabled
public boolean isTraceEnabled()- Specified by:
isTraceEnabledin interfaceorg.slf4j.Logger
-
isTraceEnabled
public boolean isTraceEnabled(org.slf4j.Marker marker) - Specified by:
isTraceEnabledin interfaceorg.slf4j.Logger
-
isErrorEnabled
public boolean isErrorEnabled()- Specified by:
isErrorEnabledin interfaceorg.slf4j.Logger
-
isErrorEnabled
public boolean isErrorEnabled(org.slf4j.Marker marker) - Specified by:
isErrorEnabledin interfaceorg.slf4j.Logger
-
isWarnEnabled
public boolean isWarnEnabled()- Specified by:
isWarnEnabledin interfaceorg.slf4j.Logger
-
isWarnEnabled
public boolean isWarnEnabled(org.slf4j.Marker marker) - Specified by:
isWarnEnabledin interfaceorg.slf4j.Logger
-
isEnabledFor
-
isEnabledFor
-
warn
- Specified by:
warnin interfaceorg.slf4j.Logger
-
warn
- Specified by:
warnin interfaceorg.slf4j.Logger
-
warn
- Specified by:
warnin interfaceorg.slf4j.Logger
-
warn
- Specified by:
warnin interfaceorg.slf4j.Logger
-
warn
- Specified by:
warnin interfaceorg.slf4j.Logger
-
warn
- Specified by:
warnin interfaceorg.slf4j.Logger
-
warn
- Specified by:
warnin interfaceorg.slf4j.Logger
-
warn
- Specified by:
warnin interfaceorg.slf4j.Logger
-
warn
- Specified by:
warnin interfaceorg.slf4j.Logger
-
warn
- Specified by:
warnin interfaceorg.slf4j.Logger
-
isAdditive
public boolean isAdditive() -
setAdditive
public void setAdditive(boolean additive) -
toString
-
callTurboFilters
Method that calls the attached TurboFilter objects based on the logger and the level. It is used by isYYYEnabled() methods. It returns the typical FilterReply values: ACCEPT, NEUTRAL or DENY.- Parameters:
level-- Returns:
- the reply given by the TurboFilters
-
getLoggerContext
Return the context for this logger.- Returns:
- the context
-
log
public void log(org.slf4j.Marker marker, String fqcn, int levelInt, String message, Object[] argArray, Throwable t) - Specified by:
login interfaceorg.slf4j.spi.LocationAwareLogger
-
log
public void log(org.slf4j.event.LoggingEvent slf4jEvent) Support SLF4J interception during initialization as introduced in SLF4J version 1.7.15- Parameters:
slf4jEvent-- Since:
- 1.1.4
-
readResolve
After serialization, the logger instance does not know its LoggerContext. The best we can do here, is to return a logger with the same name returned by org.slf4j.LoggerFactory.- Returns:
- Logger instance with the same name
- Throws:
ObjectStreamException
-