org.apache.logging.log4j.core.config
Class LoggerConfig

java.lang.Object
  extended by org.apache.logging.log4j.core.filter.AbstractFilterable
      extended by org.apache.logging.log4j.core.config.LoggerConfig
All Implemented Interfaces:
Filterable, LogEventFactory
Direct Known Subclasses:
AsyncLoggerConfig, AsyncLoggerConfig.RootLogger, LoggerConfig.RootLogger

public class LoggerConfig
extends AbstractFilterable
implements LogEventFactory

Logger object that is created via configuration.


Nested Class Summary
static class LoggerConfig.RootLogger
          The root Logger.
 
Constructor Summary
  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)
           
 
Method Summary
 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.
 LogEvent createEvent(String loggerName, org.apache.logging.log4j.Marker marker, String fqcn, org.apache.logging.log4j.Level level, org.apache.logging.log4j.message.Message data, List<Property> properties, Throwable t)
          Creates a log event.
static LoggerConfig createLogger(String additivity, String levelName, String loggerName, String includeLocation, AppenderRef[] refs, Property[] properties, Configuration config, Filter filter)
          Factory method to create a LoggerConfig.
 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()
          Returns an unmodifiable map with the configuration properties, or null if this LoggerConfig does not have any configuration properties.
 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.
 void log(LogEvent event)
          Logs an event.
 void log(String loggerName, org.apache.logging.log4j.Marker marker, String fqcn, 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.
 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()
           
 
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, hasFilter, isFiltered, removeFilter, startFilter, stopFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LoggerConfig

public LoggerConfig()
Default constructor.


LoggerConfig

public LoggerConfig(String name,
                    org.apache.logging.log4j.Level level,
                    boolean additive)
Constructor that sets the name, level and additive values.

Parameters:
name - The Logger name.
level - The Level.
additive - true if the Logger is additive, false otherwise.

LoggerConfig

protected LoggerConfig(String name,
                       List<AppenderRef> appenders,
                       Filter filter,
                       org.apache.logging.log4j.Level level,
                       boolean additive,
                       Property[] properties,
                       Configuration config,
                       boolean includeLocation)
Method Detail

getFilter

public Filter getFilter()
Description copied from class: AbstractFilterable
Returns the Filter.

Specified by:
getFilter in interface Filterable
Overrides:
getFilter in class AbstractFilterable
Returns:
the Filter.

getName

public String getName()
Returns the name of the LoggerConfig.

Returns:
the name of the LoggerConfig.

setParent

public void setParent(LoggerConfig parent)
Sets the parent of this LoggerConfig.

Parameters:
parent - the parent LoggerConfig.

getParent

public LoggerConfig getParent()
Returns the parent of this LoggerConfig.

Returns:
the LoggerConfig that is the parent of this one.

addAppender

public void addAppender(Appender appender,
                        org.apache.logging.log4j.Level level,
                        Filter filter)
Adds an Appender to the LoggerConfig.

Parameters:
appender - The Appender to add.
level - The Level to use.
filter - A Filter for the Appender reference.

removeAppender

public void removeAppender(String name)
Removes the Appender with the specific name.

Parameters:
name - The name of the Appender.

getAppenders

public Map<String,Appender<?>> getAppenders()
Returns all Appenders as a Map.

Returns:
a Map with the Appender name as the key and the Appender as the value.

clearAppenders

protected void clearAppenders()
Removes all Appenders.


getAppenderRefs

public List<AppenderRef> getAppenderRefs()
Returns the Appender references.

Returns:
a List of all the Appender names attached to this LoggerConfig.

setLevel

public void setLevel(org.apache.logging.log4j.Level level)
Sets the logging Level.

Parameters:
level - The logging Level.

getLevel

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

Returns:
the logging Level.

getLogEventFactory

public LogEventFactory getLogEventFactory()
Returns the LogEventFactory.

Returns:
the LogEventFactory.

setLogEventFactory

public void setLogEventFactory(LogEventFactory logEventFactory)
Sets the LogEventFactory. Usually the LogEventFactory will be this LoggerConfig.

Parameters:
logEventFactory - the LogEventFactory.

isAdditive

public boolean isAdditive()
Returns the valid of the additive flag.

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

setAdditive

public void setAdditive(boolean additive)
Sets the additive setting.

Parameters:
additive - true if the LoggerConfig should be additive, false otherwise.

isIncludeLocation

public 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.

Returns:
whether location should be passed downstream

getProperties

public Map<Property,Boolean> getProperties()
Returns an unmodifiable map with the configuration properties, or null 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.

Returns:
an unmodifiable map with the configuration properties, or null
See Also:
Configuration.getSubst(), StrSubstitutor

log

public void log(String loggerName,
                org.apache.logging.log4j.Marker marker,
                String fqcn,
                org.apache.logging.log4j.Level level,
                org.apache.logging.log4j.message.Message data,
                Throwable t)
Logs an event.

Parameters:
loggerName - The name of the Logger.
marker - A Marker or null if none is present.
fqcn - The fully qualified class name of the caller.
level - The event Level.
data - The Message.
t - A Throwable or null.

log

public void log(LogEvent event)
Logs an event.

Parameters:
event - The log event.

callAppenders

protected void callAppenders(LogEvent event)

createEvent

public LogEvent createEvent(String loggerName,
                            org.apache.logging.log4j.Marker marker,
                            String fqcn,
                            org.apache.logging.log4j.Level level,
                            org.apache.logging.log4j.message.Message data,
                            List<Property> properties,
                            Throwable t)
Creates a log event.

Specified by:
createEvent in interface LogEventFactory
Parameters:
loggerName - The name of the Logger.
marker - An optional Marker.
fqcn - The fully qualified class name of the caller.
level - The event Level.
data - The Message.
properties - Properties to be added to the log event.
t - An optional Throwable.
Returns:
The LogEvent.

toString

public String toString()
Overrides:
toString in class Object

createLogger

public static LoggerConfig createLogger(String additivity,
                                        String levelName,
                                        String loggerName,
                                        String includeLocation,
                                        AppenderRef[] refs,
                                        Property[] properties,
                                        Configuration config,
                                        Filter filter)
Factory method to create a LoggerConfig.

Parameters:
additivity - True if additive, false otherwise.
levelName - The Level to be associated with the Logger.
loggerName - The name of the Logger.
includeLocation - whether location should be passed downstream
refs - An array of Appender names.
properties - Properties to pass to the Logger.
config - The Configuration.
filter - A Filter.
Returns:
A new LoggerConfig.


Copyright © 1999-2013 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.