org.apache.sling.commons.log.internal.slf4j
Class LogConfigManager

java.lang.Object
  extended by org.apache.sling.commons.log.internal.slf4j.LogConfigManager
All Implemented Interfaces:
org.slf4j.ILoggerFactory

public class LogConfigManager
extends Object
implements org.slf4j.ILoggerFactory


Field Summary
static String ROOT
           
 
Method Summary
 void close()
          Shuts this configuration manager down by dropping all references to existing configurations, dropping all stored loggers and closing all log writers.
static LogConfigManager getInstance()
          Returns the single instance of this log configuration instance.
 org.slf4j.Logger getLogger(String name)
          Returns the name logger.
static void internalFailure(String message, Throwable t)
          Logs a message an optional stack trace to error output.
 void setDefaultConfiguration(Dictionary<String,String> defaultConfiguration)
          Sets and applies the default configuration used by the updateGlobalConfiguration(Dictionary) method if no configuration is supplied.
 void setRoot(String root)
          Sets the root (folder) to be used to make relative paths absolute.
 void updateGlobalConfiguration(Dictionary<String,String> configuration)
           
 void updateLoggerConfiguration(String pid, Dictionary<?,?> configuration)
          Updates or removes the logger configuration indicated by the given pid.
 void updateLogWriter(String pid, Dictionary<?,?> configuration)
          Updates or removes the log writer configuration identified by the pid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT

public static final String ROOT
See Also:
Constant Field Values
Method Detail

getInstance

public static LogConfigManager getInstance()
Returns the single instance of this log configuration instance.


internalFailure

public static void internalFailure(String message,
                                   Throwable t)
Logs a message an optional stack trace to error output. This method is used by the logging system in case of errors writing to the correct logging output.


setRoot

public void setRoot(String root)
Sets the root (folder) to be used to make relative paths absolute.


setDefaultConfiguration

public void setDefaultConfiguration(Dictionary<String,String> defaultConfiguration)
Sets and applies the default configuration used by the updateGlobalConfiguration(Dictionary) method if no configuration is supplied.


close

public void close()
Shuts this configuration manager down by dropping all references to existing configurations, dropping all stored loggers and closing all log writers.

After this methods is called, this instance should not be used again.


getLogger

public org.slf4j.Logger getLogger(String name)
Returns the name logger. If no logger for the name already exists, it is created and configured on the fly and returned. If a logger of the same name already exists, that logger is returned.

Specified by:
getLogger in interface org.slf4j.ILoggerFactory

updateGlobalConfiguration

public void updateGlobalConfiguration(Dictionary<String,String> configuration)
                               throws ConfigurationException
Throws:
ConfigurationException

updateLogWriter

public void updateLogWriter(String pid,
                            Dictionary<?,?> configuration)
                     throws ConfigurationException
Updates or removes the log writer configuration identified by the pid. In case of log writer removal, any logger configuration referring to the removed log writer is modified to now log to the default log writer.

The configuration object is expected to contain the following properties:

LogManager.LOG_FILE
The relative of absolute path/name of the file to log to. If this property is missing or an empty string, the writer writes to standard output
LogManager.LOG_FILE_SIZE
The maximum size of the log file to write before rotating the log file. This property must be a number of be convertible to a number. The actual value may also be suffixed by a size indicator k, kb, m, mb, g or gb representing the respective factors of kilo, mega and giga.If this property is missing or cannot be converted to a number, the default value LogManager.LOG_FILE_SIZE_DEFAULT is assumed. If the writer writes standard output this property is ignored.
LogManager.LOG_FILE_NUMBER
The maximum number of rotated log files to keep. This property must be a number of be convertible to a number. If this property is missing or cannot be converted to a number, the default value LogManager.LOG_FILE_NUMBER_DEFAULT is assumed. If the writer writes standard output this property is ignored.

Parameters:
pid - The identifier of the log writer to update or remove
configuration - New configuration setting for the log writer or null to indicate to remove the log writer.
Throws:
ConfigurationException - If another log writer already exists for the same file as configured for the given log writer or if configuring the log writer fails.

updateLoggerConfiguration

public void updateLoggerConfiguration(String pid,
                                      Dictionary<?,?> configuration)
                               throws ConfigurationException
Updates or removes the logger configuration indicated by the given pid. If the case of modified categories or removal of the logger configuration, existing loggers will be modified to reflect the correct logger configurations available.

The configuration object is expected to contain the following properties:

LogManager.LOG_PATTERN
The MessageFormat pattern to apply to format the log message before writing it to the log writer. If this property is missing or the empty string the default pattern LogManager.LOG_PATTERN_DEFAULT is used.
LogManager.LOG_LEVEL
The log level to use for log message limitation. The supported values are trace, debug, info, warn and error. Case does not matter. If this property is missing a ConfigurationException is thrown and this logger configuration is not used.
LogManager.LOG_LOGGERS
The logger names to which this configuration applies. As logger names form a hierarchy like Java packages, the listed names also apply to "child names" unless more specific configuration applies for such children. This property may be a single string, an array of strings or a collection of strings. Each string may itself be a comma-separated list of logger names. If this property is missing a ConfigurationException is thrown.
LogManager.LOG_FILE
The name of the log writer to use. This may be the name of a log file configured for any log writer or it may be the configuration PID of such a writer. If this property is missing or empty or does not refer to an existing log writer configuration, the default log writer is used.

Parameters:
pid - The name of the configuration to update or remove.
configuration - The configuration object.
Throws:
ConfigurationException - If the log level and logger names properties are not configured for the given configuration.


Copyright © 2007-2013 The Apache Software Foundation. All Rights Reserved.