@Plugin(name="logger", category="Core", printObject=true) public class LoggerConfig extends AbstractFilterable implements LocationAware
Modifier and Type | Class and Description |
---|---|
protected static class |
LoggerConfig.LoggerConfigPredicate |
static class |
LoggerConfig.RootLogger
The root Logger.
|
AbstractFilterable.Builder<B extends AbstractFilterable.Builder<B>>
LifeCycle.State
Modifier and Type | Field and Description |
---|---|
static String |
ROOT |
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
Modifier | Constructor and Description |
---|---|
|
LoggerConfig()
Default constructor.
|
|
LoggerConfig(String name,
org.apache.logging.log4j.Level level,
boolean additive)
Constructor that sets the name, level and additive values.
|
protected |
LoggerConfig(String name,
List<AppenderRef> appenders,
Filter filter,
org.apache.logging.log4j.Level level,
boolean additive,
Property[] properties,
Configuration config,
boolean includeLocation) |
Modifier and Type | Method and Description |
---|---|
void |
addAppender(Appender appender,
org.apache.logging.log4j.Level level,
Filter filter)
Adds an Appender to the LoggerConfig.
|
protected void |
callAppenders(LogEvent event) |
protected void |
clearAppenders()
Removes all Appenders.
|
static LoggerConfig |
createLogger(boolean additivity,
org.apache.logging.log4j.Level level,
String loggerName,
String includeLocation,
AppenderRef[] refs,
Property[] properties,
Configuration config,
Filter filter)
Factory method to create a LoggerConfig.
|
static LoggerConfig |
createLogger(String additivity,
org.apache.logging.log4j.Level level,
String loggerName,
String includeLocation,
AppenderRef[] refs,
Property[] properties,
Configuration config,
Filter filter)
Deprecated.
|
List<AppenderRef> |
getAppenderRefs()
Returns the Appender references.
|
Map<String,Appender> |
getAppenders()
Returns all Appenders as a Map.
|
Filter |
getFilter()
Returns the Filter.
|
org.apache.logging.log4j.Level |
getLevel()
Returns the logging Level.
|
LogEventFactory |
getLogEventFactory()
Returns the LogEventFactory.
|
String |
getName()
Returns the name of the LoggerConfig.
|
LoggerConfig |
getParent()
Returns the parent of this LoggerConfig.
|
Map<Property,Boolean> |
getProperties()
Deprecated.
use
getPropertyList() instead |
List<Property> |
getPropertyList()
Returns an unmodifiable list with the configuration properties, or
null if this LoggerConfig does
not have any configuration properties. |
ReliabilityStrategy |
getReliabilityStrategy()
Returns the object responsible for ensuring log events are delivered to a working appender, even during or after
a reconfiguration.
|
protected boolean |
hasAppenders() |
protected static boolean |
includeLocation(String includeLocationConfigValue)
Deprecated.
Please use
includeLocation(String, Configuration) |
protected static boolean |
includeLocation(String includeLocationConfigValue,
Configuration configuration) |
boolean |
isAdditive()
Returns the valid of the additive flag.
|
boolean |
isIncludeLocation()
Returns the value of logger configuration attribute
includeLocation , or, if no such attribute was
configured, true if logging is synchronous or false if logging is asynchronous. |
boolean |
isPropertiesRequireLookup() |
void |
log(LogEvent event)
Logs an event.
|
protected void |
log(LogEvent event,
LoggerConfig.LoggerConfigPredicate predicate)
Logs an event.
|
void |
log(String loggerName,
String fqcn,
org.apache.logging.log4j.Marker marker,
org.apache.logging.log4j.Level level,
org.apache.logging.log4j.message.Message data,
Throwable t)
Logs an event.
|
void |
log(String loggerName,
String fqcn,
StackTraceElement location,
org.apache.logging.log4j.Marker marker,
org.apache.logging.log4j.Level level,
org.apache.logging.log4j.message.Message data,
Throwable t)
Logs an event.
|
void |
removeAppender(String name)
Removes the Appender with the specific name.
|
boolean |
requiresLocation() |
void |
setAdditive(boolean additive)
Sets the additive setting.
|
void |
setLevel(org.apache.logging.log4j.Level level)
Sets the logging Level.
|
void |
setLogEventFactory(LogEventFactory logEventFactory)
Sets the LogEventFactory.
|
void |
setParent(LoggerConfig parent)
Sets the parent of this LoggerConfig.
|
String |
toString() |
addFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, start, stop, stop
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
public static final String ROOT
public LoggerConfig()
public LoggerConfig(String name, org.apache.logging.log4j.Level level, boolean additive)
name
- The Logger name.level
- The Level.additive
- true if the Logger is additive, false otherwise.protected LoggerConfig(String name, List<AppenderRef> appenders, Filter filter, org.apache.logging.log4j.Level level, boolean additive, Property[] properties, Configuration config, boolean includeLocation)
public Filter getFilter()
AbstractFilterable
getFilter
in interface Filterable
getFilter
in class AbstractFilterable
public String getName()
public void setParent(LoggerConfig parent)
parent
- the parent LoggerConfig.public LoggerConfig getParent()
public void addAppender(Appender appender, org.apache.logging.log4j.Level level, Filter filter)
appender
- The Appender to add.level
- The Level to use.filter
- A Filter for the Appender reference.public void removeAppender(String name)
name
- The name of the Appender.public Map<String,Appender> getAppenders()
protected void clearAppenders()
public List<AppenderRef> getAppenderRefs()
public void setLevel(org.apache.logging.log4j.Level level)
level
- The logging Level.public org.apache.logging.log4j.Level getLevel()
public LogEventFactory getLogEventFactory()
public void setLogEventFactory(LogEventFactory logEventFactory)
logEventFactory
- the LogEventFactory.public boolean isAdditive()
public void setAdditive(boolean additive)
additive
- true if the LoggerConfig should be additive, false otherwise.public boolean isIncludeLocation()
includeLocation
, or, if no such attribute was
configured, true
if logging is synchronous or false
if logging is asynchronous.@Deprecated public Map<Property,Boolean> getProperties()
getPropertyList()
insteadnull
if this LoggerConfig
does
not have any configuration properties.
For each Property
key in the map, the value is true
if the property value has a variable that
needs to be substituted.
null
Configuration.getStrSubstitutor()
,
StrSubstitutor
public List<Property> getPropertyList()
null
if this LoggerConfig
does
not have any configuration properties.
Each Property
in the list has an attribute valueNeedsLookup
that
is true
if the property value has a variable that needs to be substituted.
null
Configuration.getStrSubstitutor()
,
StrSubstitutor
public boolean isPropertiesRequireLookup()
public void log(String loggerName, String fqcn, org.apache.logging.log4j.Marker marker, org.apache.logging.log4j.Level level, org.apache.logging.log4j.message.Message data, Throwable t)
loggerName
- The name of the Logger.fqcn
- The fully qualified class name of the caller.marker
- A Marker or null if none is present.level
- The event Level.data
- The Message.t
- A Throwable or null.public void log(String loggerName, String fqcn, StackTraceElement location, org.apache.logging.log4j.Marker marker, org.apache.logging.log4j.Level level, org.apache.logging.log4j.message.Message data, Throwable t)
loggerName
- The name of the Logger.fqcn
- The fully qualified class name of the caller.location
- the location of the caller.marker
- A Marker or null if none is present.level
- The event Level.data
- The Message.t
- A Throwable or null.protected void log(LogEvent event, LoggerConfig.LoggerConfigPredicate predicate)
event
- The log event.predicate
- predicate for which LoggerConfig instances to append to.
A null value is equivalent to a true predicate.public ReliabilityStrategy getReliabilityStrategy()
public boolean requiresLocation()
requiresLocation
in interface LocationAware
protected void callAppenders(LogEvent event)
@Deprecated public static LoggerConfig createLogger(String additivity, org.apache.logging.log4j.Level level, @PluginAttribute(value="name") String loggerName, String includeLocation, AppenderRef[] refs, Property[] properties, @PluginConfiguration Configuration config, Filter filter)
createLogger(boolean, Level, String, String, AppenderRef[], Property[], Configuration, Filter)
additivity
- True if additive, false otherwise.level
- The Level to be associated with the Logger.loggerName
- The name of the Logger.includeLocation
- whether location should be passed downstreamrefs
- An array of Appender names.properties
- Properties to pass to the Logger.config
- The Configuration.filter
- A Filter.@PluginFactory public static LoggerConfig createLogger(@PluginAttribute(value="additivity",defaultBoolean=true) boolean additivity, @PluginAttribute(value="level") org.apache.logging.log4j.Level level, @Required(message="Loggers cannot be configured without a name") @PluginAttribute(value="name") String loggerName, @PluginAttribute(value="includeLocation") String includeLocation, @PluginElement(value="AppenderRef") AppenderRef[] refs, @PluginElement(value="Properties") Property[] properties, @PluginConfiguration Configuration config, @PluginElement(value="Filter") Filter filter)
additivity
- true if additive, false otherwise.level
- The Level to be associated with the Logger.loggerName
- The name of the Logger.includeLocation
- whether location should be passed downstreamrefs
- An array of Appender names.properties
- Properties to pass to the Logger.config
- The Configuration.filter
- A Filter.@Deprecated protected static boolean includeLocation(String includeLocationConfigValue)
includeLocation(String, Configuration)
protected static boolean includeLocation(String includeLocationConfigValue, Configuration configuration)
protected final boolean hasAppenders()
Copyright © 1999-2020 The 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.