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 boolean
Additivity is set to true by default, that is children inherit the appenders of their ancestors by default.The children of this logger.private int
static final String
The fully qualified name of this class.private Level
(package private) final LoggerContext
private String
The name of this loggerprivate Logger
The parent of this category.private static final long
Fields inherited from interface org.slf4j.spi.LocationAwareLogger
DEBUG_INT, ERROR_INT, INFO_INT, TRACE_INT, WARN_INT
Fields inherited from interface org.slf4j.Logger
ROOT_LOGGER_NAME
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAppender
(Appender<ILoggingEvent> newAppender) Add an appender.private int
private void
buildLoggingEventAndAppend
(String localFQCN, org.slf4j.Marker marker, Level level, String msg, Object[] params, Throwable t) void
callAppenders
(ILoggingEvent event) Invoke all the appenders of this logger.private FilterReply
callTurboFilters
(org.slf4j.Marker marker, Level level) Method that calls the attached TurboFilter objects based on the logger and the level.(package private) Logger
createChildByLastNamePart
(String lastPart) Create a child of this logger by suffix, that is, the part of the name extending this logger.(package private) Logger
createChildByName
(String childName) The default size of child list arrays.void
void
void
void
void
void
void
void
void
void
void
Remove all previously added appenders from this logger instance.boolean
detachAppender
(Appender<ILoggingEvent> appender) Remove the appender passed as parameter form the list of appenders.boolean
detachAppender
(String name) Detach the appender with the name passed as parameter from the list of appenders.void
void
void
void
void
void
void
void
void
void
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.private void
filterAndLog_1
(String localFQCN, org.slf4j.Marker marker, Level level, String msg, Object param, Throwable t) private void
filterAndLog_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) Logger
getChildByName
(String childName) (package private) int
getLevel()
Return the context for this logger.getName()
private void
handleParentLevelChange
(int newParentLevelInt) This method is invoked by parent logger to let this logger know that the prent's levelInt changed.void
void
void
void
void
void
void
void
void
void
boolean
boolean
isAttached
(Appender<ILoggingEvent> appender) Returnstrue
if the specified appender is in list of attached attached,false
otherwise.boolean
boolean
isDebugEnabled
(org.slf4j.Marker marker) boolean
isEnabledFor
(Level level) boolean
isEnabledFor
(org.slf4j.Marker marker, Level level) boolean
boolean
isErrorEnabled
(org.slf4j.Marker marker) boolean
boolean
isInfoEnabled
(org.slf4j.Marker marker) private boolean
boolean
boolean
isTraceEnabled
(org.slf4j.Marker marker) boolean
boolean
isWarnEnabled
(org.slf4j.Marker marker) Get an iterator for appenders contained in the parent object.private void
void
log
(org.slf4j.event.LoggingEvent slf4jEvent) Support SLF4J interception during initialization as introduced in SLF4J version 1.7.15void
log
(org.slf4j.Marker marker, String fqcn, int levelInt, String message, Object[] argArray, Throwable t) protected Object
After serialization, the logger instance does not know its LoggerContext.(package private) void
void
setAdditive
(boolean additive) void
toString()
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
-
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 tofalse
then 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 tofalse
too. 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:
getName
in 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:
detachAndStopAllAppenders
in interfaceAppenderAttachable<ILoggingEvent>
-
detachAppender
Description copied from interface:AppenderAttachable
Detach the appender with the name passed as parameter from the list of appenders.- Specified by:
detachAppender
in interfaceAppenderAttachable<ILoggingEvent>
-
addAppender
Description copied from interface:AppenderAttachable
Add an appender.- Specified by:
addAppender
in interfaceAppenderAttachable<ILoggingEvent>
-
isAttached
Description copied from interface:AppenderAttachable
Returnstrue
if the specified appender is in list of attached attached,false
otherwise.- Specified by:
isAttached
in interfaceAppenderAttachable<ILoggingEvent>
-
iteratorForAppenders
Description copied from interface:AppenderAttachable
Get an iterator for appenders contained in the parent object.- Specified by:
iteratorForAppenders
in interfaceAppenderAttachable<ILoggingEvent>
-
getAppender
Description copied from interface:AppenderAttachable
Get an appender by name.- Specified by:
getAppender
in 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:
detachAppender
in 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:
trace
in interfaceorg.slf4j.Logger
-
trace
- Specified by:
trace
in interfaceorg.slf4j.Logger
-
trace
- Specified by:
trace
in interfaceorg.slf4j.Logger
-
trace
- Specified by:
trace
in interfaceorg.slf4j.Logger
-
trace
- Specified by:
trace
in interfaceorg.slf4j.Logger
-
trace
- Specified by:
trace
in interfaceorg.slf4j.Logger
-
trace
- Specified by:
trace
in interfaceorg.slf4j.Logger
-
trace
- Specified by:
trace
in interfaceorg.slf4j.Logger
-
trace
- Specified by:
trace
in interfaceorg.slf4j.Logger
-
trace
- Specified by:
trace
in interfaceorg.slf4j.Logger
-
isDebugEnabled
public boolean isDebugEnabled()- Specified by:
isDebugEnabled
in interfaceorg.slf4j.Logger
-
isDebugEnabled
public boolean isDebugEnabled(org.slf4j.Marker marker) - Specified by:
isDebugEnabled
in interfaceorg.slf4j.Logger
-
debug
- Specified by:
debug
in interfaceorg.slf4j.Logger
-
debug
- Specified by:
debug
in interfaceorg.slf4j.Logger
-
debug
- Specified by:
debug
in interfaceorg.slf4j.Logger
-
debug
- Specified by:
debug
in interfaceorg.slf4j.Logger
-
debug
- Specified by:
debug
in interfaceorg.slf4j.Logger
-
debug
- Specified by:
debug
in interfaceorg.slf4j.Logger
-
debug
- Specified by:
debug
in interfaceorg.slf4j.Logger
-
debug
- Specified by:
debug
in interfaceorg.slf4j.Logger
-
debug
- Specified by:
debug
in interfaceorg.slf4j.Logger
-
debug
- Specified by:
debug
in interfaceorg.slf4j.Logger
-
error
- Specified by:
error
in interfaceorg.slf4j.Logger
-
error
- Specified by:
error
in interfaceorg.slf4j.Logger
-
error
- Specified by:
error
in interfaceorg.slf4j.Logger
-
error
- Specified by:
error
in interfaceorg.slf4j.Logger
-
error
- Specified by:
error
in interfaceorg.slf4j.Logger
-
error
- Specified by:
error
in interfaceorg.slf4j.Logger
-
error
- Specified by:
error
in interfaceorg.slf4j.Logger
-
error
- Specified by:
error
in interfaceorg.slf4j.Logger
-
error
- Specified by:
error
in interfaceorg.slf4j.Logger
-
error
- Specified by:
error
in interfaceorg.slf4j.Logger
-
isInfoEnabled
public boolean isInfoEnabled()- Specified by:
isInfoEnabled
in interfaceorg.slf4j.Logger
-
isInfoEnabled
public boolean isInfoEnabled(org.slf4j.Marker marker) - Specified by:
isInfoEnabled
in interfaceorg.slf4j.Logger
-
info
- Specified by:
info
in interfaceorg.slf4j.Logger
-
info
- Specified by:
info
in interfaceorg.slf4j.Logger
-
info
- Specified by:
info
in interfaceorg.slf4j.Logger
-
info
- Specified by:
info
in interfaceorg.slf4j.Logger
-
info
- Specified by:
info
in interfaceorg.slf4j.Logger
-
info
- Specified by:
info
in interfaceorg.slf4j.Logger
-
info
- Specified by:
info
in interfaceorg.slf4j.Logger
-
info
- Specified by:
info
in interfaceorg.slf4j.Logger
-
info
- Specified by:
info
in interfaceorg.slf4j.Logger
-
info
- Specified by:
info
in interfaceorg.slf4j.Logger
-
isTraceEnabled
public boolean isTraceEnabled()- Specified by:
isTraceEnabled
in interfaceorg.slf4j.Logger
-
isTraceEnabled
public boolean isTraceEnabled(org.slf4j.Marker marker) - Specified by:
isTraceEnabled
in interfaceorg.slf4j.Logger
-
isErrorEnabled
public boolean isErrorEnabled()- Specified by:
isErrorEnabled
in interfaceorg.slf4j.Logger
-
isErrorEnabled
public boolean isErrorEnabled(org.slf4j.Marker marker) - Specified by:
isErrorEnabled
in interfaceorg.slf4j.Logger
-
isWarnEnabled
public boolean isWarnEnabled()- Specified by:
isWarnEnabled
in interfaceorg.slf4j.Logger
-
isWarnEnabled
public boolean isWarnEnabled(org.slf4j.Marker marker) - Specified by:
isWarnEnabled
in interfaceorg.slf4j.Logger
-
isEnabledFor
-
isEnabledFor
-
warn
- Specified by:
warn
in interfaceorg.slf4j.Logger
-
warn
- Specified by:
warn
in interfaceorg.slf4j.Logger
-
warn
- Specified by:
warn
in interfaceorg.slf4j.Logger
-
warn
- Specified by:
warn
in interfaceorg.slf4j.Logger
-
warn
- Specified by:
warn
in interfaceorg.slf4j.Logger
-
warn
- Specified by:
warn
in interfaceorg.slf4j.Logger
-
warn
- Specified by:
warn
in interfaceorg.slf4j.Logger
-
warn
- Specified by:
warn
in interfaceorg.slf4j.Logger
-
warn
- Specified by:
warn
in interfaceorg.slf4j.Logger
-
warn
- Specified by:
warn
in 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:
log
in 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
-