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 Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • FQCN

      public static final String FQCN
      The fully qualified name of this class. Used in gathering caller information.
    • name

      private String name
      The name of this logger
    • level

      private transient Level level
    • effectiveLevelInt

      private transient int effectiveLevelInt
    • parent

      private transient Logger parent
      The parent of this category. All categories have at least one ancestor which is the root category.
    • childrenList

      private transient List<Logger> childrenList
      The children of this logger. A logger may have zero or more children.
    • aai

      private transient AppenderAttachableImpl<ILoggingEvent> 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 additive
      Additivity is set to true by default, that is children inherit the appenders of their ancestors by default. If this variable is set to false 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 to false too. See the user manual for more details.
    • loggerContext

      final transient LoggerContext loggerContext
  • Constructor Details

  • Method Details

    • getEffectiveLevel

      public Level getEffectiveLevel()
    • getEffectiveLevelInt

      int getEffectiveLevelInt()
    • getLevel

      public Level getLevel()
    • getName

      public String getName()
      Specified by:
      getName in interface org.slf4j.Logger
    • isRootLogger

      private boolean isRootLogger()
    • getChildByName

      Logger getChildByName(String childName)
    • setLevel

      public void setLevel(Level newLevel)
    • 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 interface AppenderAttachable<ILoggingEvent>
    • detachAppender

      public boolean detachAppender(String name)
      Description copied from interface: AppenderAttachable
      Detach the appender with the name passed as parameter from the list of appenders.
      Specified by:
      detachAppender in interface AppenderAttachable<ILoggingEvent>
    • addAppender

      public void addAppender(Appender<ILoggingEvent> newAppender)
      Description copied from interface: AppenderAttachable
      Add an appender.
      Specified by:
      addAppender in interface AppenderAttachable<ILoggingEvent>
    • isAttached

      public boolean isAttached(Appender<ILoggingEvent> appender)
      Description copied from interface: AppenderAttachable
      Returns true if the specified appender is in list of attached attached, false otherwise.
      Specified by:
      isAttached in interface AppenderAttachable<ILoggingEvent>
    • iteratorForAppenders

      public Iterator<Appender<ILoggingEvent>> iteratorForAppenders()
      Description copied from interface: AppenderAttachable
      Get an iterator for appenders contained in the parent object.
      Specified by:
      iteratorForAppenders in interface AppenderAttachable<ILoggingEvent>
    • getAppender

      public Appender<ILoggingEvent> getAppender(String name)
      Description copied from interface: AppenderAttachable
      Get an appender by name.
      Specified by:
      getAppender in interface AppenderAttachable<ILoggingEvent>
    • callAppenders

      public void callAppenders(ILoggingEvent event)
      Invoke all the appenders of this logger.
      Parameters:
      event - The event to log
    • appendLoopOnAppenders

      private int appendLoopOnAppenders(ILoggingEvent event)
    • detachAppender

      public boolean detachAppender(Appender<ILoggingEvent> appender)
      Remove the appender passed as parameter form the list of appenders.
      Specified by:
      detachAppender in interface AppenderAttachable<ILoggingEvent>
    • createChildByLastNamePart

      Logger createChildByLastNamePart(String lastPart)
      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

      Logger createChildByName(String childName)
      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

      private void filterAndLog_1(String localFQCN, org.slf4j.Marker marker, Level level, String msg, Object param, Throwable t)
    • filterAndLog_2

      private void filterAndLog_2(String localFQCN, org.slf4j.Marker marker, Level level, String msg, Object param1, Object param2, Throwable t)
    • buildLoggingEventAndAppend

      private void buildLoggingEventAndAppend(String localFQCN, org.slf4j.Marker marker, Level level, String msg, Object[] params, Throwable t)
    • trace

      public void trace(String msg)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(String format, Object arg)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(String format, Object arg1, Object arg2)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(String format, Object... argArray)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(String msg, Throwable t)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(org.slf4j.Marker marker, String msg)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(org.slf4j.Marker marker, String format, Object arg)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(org.slf4j.Marker marker, String format, Object arg1, Object arg2)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(org.slf4j.Marker marker, String format, Object... argArray)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(org.slf4j.Marker marker, String msg, Throwable t)
      Specified by:
      trace in interface org.slf4j.Logger
    • isDebugEnabled

      public boolean isDebugEnabled()
      Specified by:
      isDebugEnabled in interface org.slf4j.Logger
    • isDebugEnabled

      public boolean isDebugEnabled(org.slf4j.Marker marker)
      Specified by:
      isDebugEnabled in interface org.slf4j.Logger
    • debug

      public void debug(String msg)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(String format, Object arg)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(String format, Object arg1, Object arg2)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(String format, Object... argArray)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(String msg, Throwable t)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(org.slf4j.Marker marker, String msg)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(org.slf4j.Marker marker, String format, Object arg)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(org.slf4j.Marker marker, String format, Object arg1, Object arg2)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(org.slf4j.Marker marker, String format, Object... argArray)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(org.slf4j.Marker marker, String msg, Throwable t)
      Specified by:
      debug in interface org.slf4j.Logger
    • error

      public void error(String msg)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(String format, Object arg)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(String format, Object arg1, Object arg2)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(String format, Object... argArray)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(String msg, Throwable t)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(org.slf4j.Marker marker, String msg)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(org.slf4j.Marker marker, String format, Object arg)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(org.slf4j.Marker marker, String format, Object arg1, Object arg2)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(org.slf4j.Marker marker, String format, Object... argArray)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(org.slf4j.Marker marker, String msg, Throwable t)
      Specified by:
      error in interface org.slf4j.Logger
    • isInfoEnabled

      public boolean isInfoEnabled()
      Specified by:
      isInfoEnabled in interface org.slf4j.Logger
    • isInfoEnabled

      public boolean isInfoEnabled(org.slf4j.Marker marker)
      Specified by:
      isInfoEnabled in interface org.slf4j.Logger
    • info

      public void info(String msg)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(String format, Object arg)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(String format, Object arg1, Object arg2)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(String format, Object... argArray)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(String msg, Throwable t)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(org.slf4j.Marker marker, String msg)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(org.slf4j.Marker marker, String format, Object arg)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(org.slf4j.Marker marker, String format, Object arg1, Object arg2)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(org.slf4j.Marker marker, String format, Object... argArray)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(org.slf4j.Marker marker, String msg, Throwable t)
      Specified by:
      info in interface org.slf4j.Logger
    • isTraceEnabled

      public boolean isTraceEnabled()
      Specified by:
      isTraceEnabled in interface org.slf4j.Logger
    • isTraceEnabled

      public boolean isTraceEnabled(org.slf4j.Marker marker)
      Specified by:
      isTraceEnabled in interface org.slf4j.Logger
    • isErrorEnabled

      public boolean isErrorEnabled()
      Specified by:
      isErrorEnabled in interface org.slf4j.Logger
    • isErrorEnabled

      public boolean isErrorEnabled(org.slf4j.Marker marker)
      Specified by:
      isErrorEnabled in interface org.slf4j.Logger
    • isWarnEnabled

      public boolean isWarnEnabled()
      Specified by:
      isWarnEnabled in interface org.slf4j.Logger
    • isWarnEnabled

      public boolean isWarnEnabled(org.slf4j.Marker marker)
      Specified by:
      isWarnEnabled in interface org.slf4j.Logger
    • isEnabledFor

      public boolean isEnabledFor(org.slf4j.Marker marker, Level level)
    • isEnabledFor

      public boolean isEnabledFor(Level level)
    • warn

      public void warn(String msg)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(String msg, Throwable t)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(String format, Object arg)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(String format, Object arg1, Object arg2)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(String format, Object... argArray)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(org.slf4j.Marker marker, String msg)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(org.slf4j.Marker marker, String format, Object arg)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(org.slf4j.Marker marker, String format, Object... argArray)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(org.slf4j.Marker marker, String format, Object arg1, Object arg2)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(org.slf4j.Marker marker, String msg, Throwable t)
      Specified by:
      warn in interface org.slf4j.Logger
    • isAdditive

      public boolean isAdditive()
    • setAdditive

      public void setAdditive(boolean additive)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • callTurboFilters

      private FilterReply callTurboFilters(org.slf4j.Marker marker, Level level)
      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

      public LoggerContext 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 interface org.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

      protected Object readResolve() throws ObjectStreamException
      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