org.apache.logging.log4j.core
Class Logger

java.lang.Object
  extended by org.apache.logging.log4j.spi.AbstractLogger
      extended by org.apache.logging.log4j.core.Logger
All Implemented Interfaces:
org.apache.logging.log4j.Logger

public class Logger
extends org.apache.logging.log4j.spi.AbstractLogger

Troublesome:
All the isEnabled methods could be pushed into a filter interface. Not sure of the utility of having isEnabled be able to examine the message pattern and parameters. (RG) Moving the isEnabled methods out of Logger noticeably impacts performance. The message pattern and parameters are required so that they can be used in global filters.

Nested Class Summary
protected  class Logger.PrivateConfig
          The binding between a Logger and its configuration.
 
Field Summary
protected  Logger.PrivateConfig config
          config should be consistent across threads.
 
Fields inherited from class org.apache.logging.log4j.spi.AbstractLogger
CATCHING_MARKER, ENTRY_MARKER, EXCEPTION_MARKER, EXIT_MARKER, FLOW_MARKER, THROWING_MARKER
 
Constructor Summary
protected Logger(LoggerContext context, String name)
          The constructor.
 
Method Summary
 void addAppender(Appender appender)
          This method is not exposed through the public API and is used primarily for unit testing.
 void addFilter(Filter filter)
          This method is not exposed through the public API and is used primarily for unit testing.
 int filterCount()
          This method is not exposed through the public API and is used primarily for unit testing.
 Map<String,Appender> getAppenders()
          This method is not exposed through the public API and is used primarily for unit testing.
 LoggerContext getContext()
          Returns the LoggerContext this Logger is associated with.
 Iterator<Filter> getFilters()
          This method is not exposed through the public API and is used primarily for unit testing.
 org.apache.logging.log4j.Level getLevel()
          Returns the Level associated with the Logger.
 Logger getParent()
          Returns the parent of this Logger.
 boolean isAdditive()
          This method is not exposed through the public API and is present only to support the Log4j 1.2 compatibility bridge.
 boolean isEnabled(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, org.apache.logging.log4j.message.Message msg, Throwable t)
           
 boolean isEnabled(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, Object msg, Throwable t)
           
 boolean isEnabled(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, String msg)
           
 boolean isEnabled(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, String msg, Object... p1)
           
 boolean isEnabled(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, String msg, Throwable t)
           
 void log(org.apache.logging.log4j.Marker marker, String fqcn, org.apache.logging.log4j.Level level, org.apache.logging.log4j.message.Message data, Throwable t)
           
 void removeAppender(Appender appender)
          This method is not exposed through the public API and is used primarily for unit testing.
 void setAdditive(boolean additive)
          This method is not exposed through the public API and is present only to support the Log4j 1.2 compatibility bridge.
 void setLevel(org.apache.logging.log4j.Level level)
          This method is not exposed through the public API and is provided primarily for unit testing.
 String toString()
          Returns a String representation of this instance in the form "name:level[ in context_name]".
 
Methods inherited from class org.apache.logging.log4j.spi.AbstractLogger
catching, catching, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, entry, entry, error, error, error, error, error, error, error, error, error, error, error, error, error, error, exit, exit, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, getName, info, info, info, info, info, info, info, info, info, info, info, info, info, info, isDebugEnabled, isDebugEnabled, isEnabled, isErrorEnabled, isErrorEnabled, isFatalEnabled, isFatalEnabled, isInfoEnabled, isInfoEnabled, isTraceEnabled, isTraceEnabled, isWarnEnabled, isWarnEnabled, throwing, throwing, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

config

protected volatile Logger.PrivateConfig config
config should be consistent across threads.

Constructor Detail

Logger

protected Logger(LoggerContext context,
                 String name)
The constructor.

Parameters:
context - The LoggerContext this Logger is associated with.
name - The name of the Logger.
Method Detail

getParent

public Logger getParent()
Returns the parent of this Logger. If it doesn't already exist return a temporary Logger.

Returns:
The parent Logger.

getContext

public LoggerContext getContext()
Returns the LoggerContext this Logger is associated with.

Returns:
the LoggerContext.

setLevel

public void setLevel(org.apache.logging.log4j.Level level)
This method is not exposed through the public API and is provided primarily for unit testing.

Parameters:
level - The Level to use on this Logger.

getLevel

public org.apache.logging.log4j.Level getLevel()
Returns the Level associated with the Logger.

Returns:
the Level associate with the Logger.

log

public void log(org.apache.logging.log4j.Marker marker,
                String fqcn,
                org.apache.logging.log4j.Level level,
                org.apache.logging.log4j.message.Message data,
                Throwable t)
Specified by:
log in class org.apache.logging.log4j.spi.AbstractLogger

isEnabled

public boolean isEnabled(org.apache.logging.log4j.Level level,
                         org.apache.logging.log4j.Marker marker,
                         String msg)
Specified by:
isEnabled in class org.apache.logging.log4j.spi.AbstractLogger

isEnabled

public boolean isEnabled(org.apache.logging.log4j.Level level,
                         org.apache.logging.log4j.Marker marker,
                         String msg,
                         Throwable t)
Specified by:
isEnabled in class org.apache.logging.log4j.spi.AbstractLogger

isEnabled

public boolean isEnabled(org.apache.logging.log4j.Level level,
                         org.apache.logging.log4j.Marker marker,
                         String msg,
                         Object... p1)
Specified by:
isEnabled in class org.apache.logging.log4j.spi.AbstractLogger

isEnabled

public boolean isEnabled(org.apache.logging.log4j.Level level,
                         org.apache.logging.log4j.Marker marker,
                         Object msg,
                         Throwable t)
Specified by:
isEnabled in class org.apache.logging.log4j.spi.AbstractLogger

isEnabled

public boolean isEnabled(org.apache.logging.log4j.Level level,
                         org.apache.logging.log4j.Marker marker,
                         org.apache.logging.log4j.message.Message msg,
                         Throwable t)
Specified by:
isEnabled in class org.apache.logging.log4j.spi.AbstractLogger

addAppender

public void addAppender(Appender appender)
This method is not exposed through the public API and is used primarily for unit testing.

Parameters:
appender - The Appender to add to the Logger.

removeAppender

public void removeAppender(Appender appender)
This method is not exposed through the public API and is used primarily for unit testing.

Parameters:
appender - The Appender to remove from the Logger.

getAppenders

public Map<String,Appender> getAppenders()
This method is not exposed through the public API and is used primarily for unit testing.

Returns:
A Map containing the Appender's name as the key and the Appender as the value.

getFilters

public Iterator<Filter> getFilters()
This method is not exposed through the public API and is used primarily for unit testing.

Returns:
An Iterator over all the Filters associated with the Logger.

filterCount

public int filterCount()
This method is not exposed through the public API and is used primarily for unit testing.

Returns:
The number of Filters associated with the Logger.

addFilter

public void addFilter(Filter filter)
This method is not exposed through the public API and is used primarily for unit testing.

Parameters:
filter - The Filter to add.

isAdditive

public boolean isAdditive()
This method is not exposed through the public API and is present only to support the Log4j 1.2 compatibility bridge.

Returns:
true if the associated LoggerConfig is additive, false otherwise.

setAdditive

public void setAdditive(boolean additive)
This method is not exposed through the public API and is present only to support the Log4j 1.2 compatibility bridge.

Parameters:
additive - Boolean value to indicate whether the Logger is additive or not.

toString

public String toString()
Returns a String representation of this instance in the form "name:level[ in context_name]".

Overrides:
toString in class org.apache.logging.log4j.spi.AbstractLogger
Returns:
A String describing this Logger instance.


Copyright © 1999-2012 Apache Software Foundation. All Rights Reserved. Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, and the Apache Logging project logo are trademarks of The Apache Software Foundation.