Apache Log4cxx  Version 1.3.0
Loading...
Searching...
No Matches
log4cxx::DefaultConfigurator Class Reference

Configures the repository from environmental settings and files. More...

#include <defaultconfigurator.h>

Static Public Member Functions

static void configure (spi::LoggerRepositoryPtr repository)
 Configure repository.
 
static void setConfigurationFileName (const LogString &path)
 Make path the configuration file used by configure().
 
static void setConfigurationWatchSeconds (int seconds)
 Make seconds the time a background thread will delay before checking for a change to the configuration file used by configure().
 
static std::tuple< log4cxx::spi::ConfigurationStatus, LogStringconfigureFromFile (const std::vector< LogString > &directories, const std::vector< LogString > &filenames)
 Configure Log4cxx from a file.
 

Detailed Description

Configures the repository from environmental settings and files.

Member Function Documentation

◆ configure()

static void log4cxx::DefaultConfigurator::configure ( spi::LoggerRepositoryPtr  repository)
static

Configure repository.

If the configuration file name has not been provided by a call to setConfigurationFileName(), the environment variables "LOG4CXX_CONFIGURATION" and "log4j.configuration" are examined. Unless a custom configurator is specified using the "LOG4CXX_CONFIGURATOR_CLASS" or "log4j.configuratorClass" environment variable, the PropertyConfigurator will be used to configure log4cxx unless the file name ends with the ".xml" extension, in which case the DOMConfigurator will be used. If a custom configurator is specified, the environment variable should contain a fully qualified class name of a class that implements the Configurator interface.

If the configuration file name is not found using any of the previous approaches, the current directory is examined for a file with extension ".xml" or ".properties" with a base name "log4cxx" or "log4j".

If a positive number has been provided by a call to setConfigurationWatchSeconds() or the environment variables "LOG4CXX_CONFIGURATION_WATCH_SECONDS" contains a positive number a background thread is started that will periodically check for a change to the configuration file and apply any configuration changes found.

◆ configureFromFile()

static std::tuple< log4cxx::spi::ConfigurationStatus, LogString > log4cxx::DefaultConfigurator::configureFromFile ( const std::vector< LogString > &  directories,
const std::vector< LogString > &  filenames 
)
static

Configure Log4cxx from a file.

This method will attempt to load the configuration files in the directories given.

For example, if we want a configuration file named 'myapp-logging.xml' with the default location for this file in /etc/myapp, but to have this overriden by a file in /usr/local/etc/myapp, we would call this function as follows:

configureFromFile( { "/usr/local/etc/myapp", "/etc/myapp" }, { "myapp-logging.xml" );

This will then search for files in the following order:

/usr/local/etc/myapp/myapp-logging.xml
/etc/myapp/myapp-logging.xml

The status of configuring Log4cxx as well as the eventual filename used is returned. If a file exists but it is not able to be used to configure Log4cxx, the next file in the list will be tried until a valid configuration file is found or the end of the list is reached.

Parameters
directoriesThe directories to look in.
filenamesThe names of the files to look for
Returns
The status of the configuration, and the filename loaded(if a file was found).

◆ setConfigurationFileName()

static void log4cxx::DefaultConfigurator::setConfigurationFileName ( const LogString path)
static

Make path the configuration file used by configure().

◆ setConfigurationWatchSeconds()

static void log4cxx::DefaultConfigurator::setConfigurationWatchSeconds ( int  seconds)
static

Make seconds the time a background thread will delay before checking for a change to the configuration file used by configure().


The documentation for this class was generated from the following file: