@Plugin(name="logger", category="Core", printObject=true) public class LoggerConfig extends AbstractFilterable
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 |
---|---|
private boolean |
additive |
private java.util.List<AppenderRef> |
appenderRefs |
private AppenderControlArraySet |
appenders |
private Configuration |
config |
private boolean |
includeLocation |
private Level |
level |
private static LogEventFactory |
LOG_EVENT_FACTORY |
private LogEventFactory |
logEventFactory |
private java.lang.String |
name |
private LoggerConfig |
parent |
private java.util.List<Property> |
properties |
private java.util.Map<Property,java.lang.Boolean> |
propertiesMap |
private boolean |
propertiesRequireLookup |
private ReliabilityStrategy |
reliabilityStrategy |
static java.lang.String |
ROOT |
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
Modifier | Constructor and Description |
---|---|
|
LoggerConfig()
Default constructor.
|
|
LoggerConfig(java.lang.String name,
Level level,
boolean additive)
Constructor that sets the name, level and additive values.
|
protected |
LoggerConfig(java.lang.String name,
java.util.List<AppenderRef> appenders,
Filter filter,
Level level,
boolean additive,
Property[] properties,
Configuration config,
boolean includeLocation) |
Modifier and Type | Method and Description |
---|---|
void |
addAppender(Appender appender,
Level level,
Filter filter)
Adds an Appender to the LoggerConfig.
|
protected void |
callAppenders(LogEvent event) |
private void |
cleanupFilter(AppenderControl ctl) |
protected void |
clearAppenders()
Removes all Appenders.
|
private static boolean |
containsPropertyRequiringLookup(Property[] properties) |
static LoggerConfig |
createLogger(boolean additivity,
Level level,
java.lang.String loggerName,
java.lang.String includeLocation,
AppenderRef[] refs,
Property[] properties,
Configuration config,
Filter filter)
Factory method to create a LoggerConfig.
|
static LoggerConfig |
createLogger(java.lang.String additivity,
Level level,
java.lang.String loggerName,
java.lang.String includeLocation,
AppenderRef[] refs,
Property[] properties,
Configuration config,
Filter filter)
Deprecated.
|
java.util.List<AppenderRef> |
getAppenderRefs()
Returns the Appender references.
|
java.util.Map<java.lang.String,Appender> |
getAppenders()
Returns all Appenders as a Map.
|
Filter |
getFilter()
Returns the Filter.
|
Level |
getLevel()
Returns the logging Level.
|
LogEventFactory |
getLogEventFactory()
Returns the LogEventFactory.
|
java.lang.String |
getName()
Returns the name of the LoggerConfig.
|
LoggerConfig |
getParent()
Returns the parent of this LoggerConfig.
|
java.util.Map<Property,java.lang.Boolean> |
getProperties()
Deprecated.
use
getPropertyList() instead |
java.util.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(java.lang.String includeLocationConfigValue)
Deprecated.
Please use
includeLocation(String, Configuration) |
protected static boolean |
includeLocation(java.lang.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(java.lang.String loggerName,
java.lang.String fqcn,
Marker marker,
Level level,
Message data,
java.lang.Throwable t)
Logs an event.
|
private void |
logParent(LogEvent event,
LoggerConfig.LoggerConfigPredicate predicate) |
private void |
processLogEvent(LogEvent event,
LoggerConfig.LoggerConfigPredicate predicate) |
void |
removeAppender(java.lang.String name)
Removes the Appender with the specific name.
|
void |
setAdditive(boolean additive)
Sets the additive setting.
|
void |
setLevel(Level level)
Sets the logging Level.
|
void |
setLogEventFactory(LogEventFactory logEventFactory)
Sets the LogEventFactory.
|
void |
setParent(LoggerConfig parent)
Sets the parent of this LoggerConfig.
|
java.lang.String |
toString() |
addFilter, 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 java.lang.String ROOT
private static LogEventFactory LOG_EVENT_FACTORY
private java.util.List<AppenderRef> appenderRefs
private final AppenderControlArraySet appenders
private final java.lang.String name
private LogEventFactory logEventFactory
private Level level
private boolean additive
private boolean includeLocation
private LoggerConfig parent
private java.util.Map<Property,java.lang.Boolean> propertiesMap
private final java.util.List<Property> properties
private final boolean propertiesRequireLookup
private final Configuration config
private final ReliabilityStrategy reliabilityStrategy
public LoggerConfig()
public LoggerConfig(java.lang.String name, Level level, boolean additive)
name
- The Logger name.level
- The Level.additive
- true if the Logger is additive, false otherwise.protected LoggerConfig(java.lang.String name, java.util.List<AppenderRef> appenders, Filter filter, Level level, boolean additive, Property[] properties, Configuration config, boolean includeLocation)
private static boolean containsPropertyRequiringLookup(Property[] properties)
public Filter getFilter()
AbstractFilterable
getFilter
in interface Filterable
getFilter
in class AbstractFilterable
public java.lang.String getName()
public void setParent(LoggerConfig parent)
parent
- the parent LoggerConfig.public LoggerConfig getParent()
public void addAppender(Appender appender, Level level, Filter filter)
appender
- The Appender to add.level
- The Level to use.filter
- A Filter for the Appender reference.public void removeAppender(java.lang.String name)
name
- The name of the Appender.public java.util.Map<java.lang.String,Appender> getAppenders()
protected void clearAppenders()
private void cleanupFilter(AppenderControl ctl)
public java.util.List<AppenderRef> getAppenderRefs()
public void setLevel(Level level)
level
- The logging Level.public 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 java.util.Map<Property,java.lang.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 java.util.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(java.lang.String loggerName, java.lang.String fqcn, Marker marker, Level level, Message data, java.lang.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(LogEvent event)
event
- The log event.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()
private void processLogEvent(LogEvent event, LoggerConfig.LoggerConfigPredicate predicate)
private void logParent(LogEvent event, LoggerConfig.LoggerConfigPredicate predicate)
protected void callAppenders(LogEvent event)
public java.lang.String toString()
toString
in class java.lang.Object
@Deprecated public static LoggerConfig createLogger(java.lang.String additivity, Level level, @PluginAttribute(value="name") java.lang.String loggerName, java.lang.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") Level level, @Required(message="Loggers cannot be configured without a name") @PluginAttribute(value="name") java.lang.String loggerName, @PluginAttribute(value="includeLocation") java.lang.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(java.lang.String includeLocationConfigValue)
includeLocation(String, Configuration)
protected static boolean includeLocation(java.lang.String includeLocationConfigValue, Configuration configuration)
protected final boolean hasAppenders()