public class Logger extends org.apache.logging.log4j.spi.AbstractLogger implements org.apache.logging.log4j.util.Supplier<LoggerConfig>
Logger
interface. Besides providing an
implementation of all the Logger methods, this class also provides some convenience methods for Log4j 1.x
compatibility as well as access to the Filters
and
Appenders
associated with this Logger. Note that access to these
underlying objects is provided primarily for use in unit tests or bridging legacy Log4j 1.x code. Future versions
of this class may or may not include the various methods that are noted as not being part of the public API.
TODO 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.Modifier and Type | Class and Description |
---|---|
protected class |
Logger.PrivateConfig
The binding between a Logger and its configuration.
|
Modifier and Type | Field and Description |
---|---|
protected Logger.PrivateConfig |
privateConfig
Config should be consistent across threads.
|
Modifier | Constructor and Description |
---|---|
protected |
Logger(LoggerContext context,
String name,
org.apache.logging.log4j.message.MessageFactory messageFactory)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
LoggerConfig |
get() |
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()
Gets the Level associated with the Logger.
|
Logger |
getParent()
This method is only used for 1.x compatibility.
|
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 message,
Throwable t) |
boolean |
isEnabled(org.apache.logging.log4j.Level level,
org.apache.logging.log4j.Marker marker,
Object message,
Throwable t) |
boolean |
isEnabled(org.apache.logging.log4j.Level level,
org.apache.logging.log4j.Marker marker,
String message) |
boolean |
isEnabled(org.apache.logging.log4j.Level level,
org.apache.logging.log4j.Marker marker,
String message,
Object... params) |
boolean |
isEnabled(org.apache.logging.log4j.Level level,
org.apache.logging.log4j.Marker marker,
String message,
Throwable t) |
void |
logMessage(String fqcn,
org.apache.logging.log4j.Level level,
org.apache.logging.log4j.Marker marker,
org.apache.logging.log4j.message.Message message,
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]" . |
protected void |
updateConfiguration(Configuration newConfig)
Associates the Logger with a new Configuration.
|
catching, catching, catching, catchingMsg, checkMessageFactory, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, entry, entry, entry, entryMsg, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, error, exit, exit, exit, exitMsg, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, fatal, getMessageFactory, getName, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, info, isDebugEnabled, isDebugEnabled, isEnabled, isEnabled, isErrorEnabled, isErrorEnabled, isFatalEnabled, isFatalEnabled, isInfoEnabled, isInfoEnabled, isTraceEnabled, isTraceEnabled, isWarnEnabled, isWarnEnabled, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, log, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logIfEnabled, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, logMessage, printf, printf, throwing, throwing, throwing, throwingMsg, trace, trace, trace, trace, trace, trace, trace, trace, trace, trace, 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, warn, warn, warn, warn, warn, warn, warn, warn, warn, warn
protected volatile Logger.PrivateConfig privateConfig
protected Logger(LoggerContext context, String name, org.apache.logging.log4j.message.MessageFactory messageFactory)
context
- The LoggerContext this Logger is associated with.messageFactory
- The message factory.name
- The name of the Logger.public Logger getParent()
public LoggerContext getContext()
public void setLevel(org.apache.logging.log4j.Level level)
If the new level is null, this logger inherits the level from its parent.
level
- The Level to use on this Logger, may be null.public LoggerConfig get()
get
in interface org.apache.logging.log4j.util.Supplier<LoggerConfig>
public void logMessage(String fqcn, org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, org.apache.logging.log4j.message.Message message, Throwable t)
logMessage
in interface org.apache.logging.log4j.spi.ExtendedLogger
public boolean isEnabled(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, String message, Throwable t)
isEnabled
in interface org.apache.logging.log4j.spi.ExtendedLogger
public boolean isEnabled(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, String message)
isEnabled
in interface org.apache.logging.log4j.spi.ExtendedLogger
public boolean isEnabled(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, String message, Object... params)
isEnabled
in interface org.apache.logging.log4j.spi.ExtendedLogger
public boolean isEnabled(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, Object message, Throwable t)
isEnabled
in interface org.apache.logging.log4j.spi.ExtendedLogger
public boolean isEnabled(org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, org.apache.logging.log4j.message.Message message, Throwable t)
isEnabled
in interface org.apache.logging.log4j.spi.ExtendedLogger
public void addAppender(Appender appender)
appender
- The Appender to add to the Logger.public void removeAppender(Appender appender)
appender
- The Appender to remove from the Logger.public Map<String,Appender> getAppenders()
public Iterator<Filter> getFilters()
public org.apache.logging.log4j.Level getLevel()
getLevel
in interface org.apache.logging.log4j.Logger
public int filterCount()
public void addFilter(Filter filter)
filter
- The Filter to add.public boolean isAdditive()
public void setAdditive(boolean additive)
additive
- Boolean value to indicate whether the Logger is additive or not.protected void updateConfiguration(Configuration newConfig)
newConfig
- The new Configuration.Copyright © 1999-2015 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.