Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
log4cxx::xml::DOMConfigurator Class Reference

Allows Loggers, Appenders, Layouts and Filters to be set up using directives in a XML format file. More...

#include <domconfigurator.h>

Inheritance diagram for log4cxx::xml::DOMConfigurator:
log4cxx::spi::Configurator log4cxx::helpers::Object

Public Member Functions

 DOMConfigurator ()
 ~DOMConfigurator ()
bool isValid (const File &configFileName) override
 Does configFileName contain directives that this class uses?
spi::ConfigurationStatus doConfigure (const File &configFileName, const spi::LoggerRepositoryPtr &target={}) override
 Apply the directives in configFileName to target.
Public Member Functions inherited from log4cxx::helpers::Object
virtual ~Object ()
virtual const helpers::Class & getClass () const =0
virtual bool instanceof (const Class &clazz) const =0
virtual const void * cast (const Class &clazz) const =0

Static Public Member Functions

static spi::ConfigurationStatus configure (const File &configFilename)
 Apply the directives in configFileName to the spi::LoggerRepository held by LogManager.
static spi::ConfigurationStatus configureAndWatch (const File &configFilename, long millisecondDelay=0)
 Apply the directives in configFileName to the spi::LoggerRepository held by LogManager.
Static Public Member Functions inherited from log4cxx::spi::Configurator
static helpers::Properties & properties ()
 The key value pairs used when expanding ${varname} instances in a configuration file.

Additional Inherited Members

Protected Member Functions inherited from log4cxx::spi::Configurator
 Configurator ()

Detailed Description

Allows Loggers, Appenders, Layouts and Filters to be set up using directives in a XML format file.

Use Log4cxx internal logging to see values read by Log4cxx. You can enable Log4cxx internal logging by setting the debug attribute in the log4j:configuration element. As in

        <log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/">
        ...
        </log4j:configuration>

There are sample XML files included in the Configuration Files and in the Log4cxx Examples.

Constructor & Destructor Documentation

◆ DOMConfigurator()

log4cxx::xml::DOMConfigurator::DOMConfigurator ( )

◆ ~DOMConfigurator()

log4cxx::xml::DOMConfigurator::~DOMConfigurator ( )

Member Function Documentation

◆ configure()

spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configure ( const File & configFilename)
static

Apply the directives in configFileName to the spi::LoggerRepository held by LogManager.

Pre-existing key-value pairs in the property map provided by spi::Configurator::properties() are used when expanding ${varname} instances in configFileName.

The existing configuration is not cleared nor reset. If you require a different behavior, call resetConfiguration before calling doConfigure.

Examples
custom-appender.cpp.

◆ configureAndWatch()

spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configureAndWatch ( const File & configFilename,
long millisecondDelay = 0 )
static

Apply the directives in configFileName to the spi::LoggerRepository held by LogManager.

Pre-existing key-value pairs in the property map provided by spi::Configurator::properties() are used when expanding ${varname} instances in configFileName.

The existing configuration is not cleared nor reset. If you require a different behavior, call resetConfiguration before calling doConfigure.

A task will be created that periodically checks whether configFilename has been created or modified. A period of log4cxx::helpers::FileWatchdog::DEFAULT_DELAY is used if delay is not a positive number. If a change or file creation is detected, then configFilename is read to configure Log4cxx.

The task will be stopped by a LogManager::shutdown call.

Parameters
configFilenameA XML format file.
millisecondDelayThe duration to wait between each check.

◆ doConfigure()

spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::doConfigure ( const File & configFileName,
const spi::LoggerRepositoryPtr & target = {} )
overridevirtual

Apply the directives in configFileName to target.

If target is not provided, the spi::LoggerRepository held by LogManager is used.

The existing configuration is not cleared nor reset. If you require a different behavior, call resetConfiguration before calling doConfigure.

Parameters
configFileNameThe file to parse
targetHolds the Logger instances.

Pre-existing key-value pairs in the property map provided by spi::Configurator::properties() are used when expanding ${varname} instances in configFileName.

Implements log4cxx::spi::Configurator.

◆ isValid()

bool log4cxx::xml::DOMConfigurator::isValid ( const File & configFileName)
overridevirtual

Does configFileName contain directives that this class uses?

Parameters
configFileNameThe file to examine

This implementation checks configFileName is a valid XML file and that the root element name is either "log4j:configuration" or "configuration".

Implements log4cxx::spi::Configurator.


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