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

Use this class to initialize the log4cxx environment using a DOM tree. More...

#include <domconfigurator.h>

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

Public Member Functions

 ~DOMConfigurator ()
 
 DOMConfigurator ()
 
 DOMConfigurator (log4cxx::helpers::Pool &p)
 
spi::ConfigurationStatus doConfigure (const File &filename, spi::LoggerRepositoryPtr repository) override
 Interpret filename as an XML file and set up Log4cxx accordingly.
 
virtual ConfigurationStatus doConfigure (const File &configFileName, spi::LoggerRepositoryPtr repository)=0
 Interpret a resource pointed by a URL and set up log4j accordingly.
 
- Public Member Functions inherited from log4cxx::helpers::Object
virtual ~Object ()
 
virtual const helpers::ClassgetClass () 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 char *filename)
 A static version of doConfigure.
 
static spi::ConfigurationStatus configure (const std::string &filename)
 A static version of doConfigure.
 
static spi::ConfigurationStatus configure (const wchar_t *filename)
 A static version of doConfigure.
 
static spi::ConfigurationStatus configure (const std::wstring &filename)
 A static version of doConfigure.
 
static spi::ConfigurationStatus configure (const std::basic_string< UniChar > &filename)
 A static version of doConfigure.
 
static spi::ConfigurationStatus configure (const CFStringRef &filename)
 A static version of doConfigure.
 
static spi::ConfigurationStatus configureAndWatch (const std::string &configFilename)
 Like configureAndWatch(const File& filename, long delay) except that the default delay as defined by log4cxx::helpers::FileWatchdog::DEFAULT_DELAY is used.
 
static spi::ConfigurationStatus configureAndWatch (const std::wstring &configFilename)
 Like configureAndWatch(const File& filename, long delay) except that the default delay as defined by log4cxx::helpers::FileWatchdog::DEFAULT_DELAY is used.
 
static spi::ConfigurationStatus configureAndWatch (const std::basic_string< UniChar > &configFilename)
 Like configureAndWatch(const File& filename, long delay) except that the default delay as defined by log4cxx::helpers::FileWatchdog::DEFAULT_DELAY is used.
 
static spi::ConfigurationStatus configureAndWatch (const CFStringRef &configFilename)
 Like configureAndWatch(const File& filename, long delay) except that the default delay as defined by log4cxx::helpers::FileWatchdog::DEFAULT_DELAY is used.
 
static spi::ConfigurationStatus configureAndWatch (const std::string &configFilename, long delay)
 Read the configuration file configFilename if it exists.
 
static spi::ConfigurationStatus configureAndWatch (const std::wstring &configFilename, long delay)
 Refer configureAndWatch(const File& filename, long delay)
 
static spi::ConfigurationStatus configureAndWatch (const std::basic_string< UniChar > &configFilename, long delay)
 Refer configureAndWatch(const File& filename, long delay)
 
static spi::ConfigurationStatus configureAndWatch (const CFStringRef &configFilename, long delay)
 Refer configureAndWatch(const File& filename, long delay)
 
static spi::ConfigurationStatus configure (const File &configFilename)
 Read configuration options from configFilename.
 
static spi::ConfigurationStatus configureAndWatch (const File &configFilename, long delay=0)
 Read configuration options from configFilename (if it exists).
 

Protected Types

typedef std::map< LogString, AppenderPtrAppenderMap
 

Protected Member Functions

AppenderPtr findAppenderByName (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *elem, apr_xml_doc *doc, const LogString &appenderName, AppenderMap &appenders)
 Used internally to parse appenders by IDREF name.
 
AppenderPtr findAppenderByReference (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *appenderRef, apr_xml_doc *doc, AppenderMap &appenders)
 Used internally to parse appenders by IDREF element.
 
AppenderPtr parseAppender (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *appenderElement, apr_xml_doc *doc, AppenderMap &appenders)
 Used internally to parse an appender element.
 
void parseErrorHandler (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *element, AppenderPtr &appender, apr_xml_doc *doc, AppenderMap &appenders)
 Used internally to parse an ErrorHandler element.
 
void parseFilters (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *element, std::vector< log4cxx::spi::FilterPtr > &filters)
 Used internally to parse a filter element.
 
void parseLogger (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *loggerElement, apr_xml_doc *doc, AppenderMap &appenders)
 Used internally to parse a logger element.
 
void parseLoggerFactory (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *factoryElement)
 Used internally to parse the logger factory element.
 
log4cxx::helpers::ObjectPtr parseTriggeringPolicy (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *factoryElement)
 Used internally to parse the logger factory element.
 
log4cxx::rolling::RollingPolicyPtr parseRollingPolicy (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *factoryElement)
 Used internally to parse the logger factory element.
 
void parseRoot (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *rootElement, apr_xml_doc *doc, AppenderMap &appenders)
 Used internally to parse the root logger element.
 
void parseChildrenOfLoggerElement (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *catElement, LoggerPtr logger, bool isRoot, apr_xml_doc *doc, AppenderMap &appenders)
 Used internally to parse the children of a logger element.
 
LayoutPtr parseLayout (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *layout_element)
 Used internally to parse a layout element.
 
void parseLevel (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *element, LoggerPtr logger, bool isRoot)
 Used internally to parse a level element.
 
void setParameter (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *elem, log4cxx::config::PropertySetter &propSetter)
 
void parse (log4cxx::helpers::Pool &p, log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *element, apr_xml_doc *doc, AppenderMap &appenders)
 Used internally to configure the log4cxx framework from an in-memory representation of an XML document.
 
LogString subst (const LogString &value)
 
- Protected Member Functions inherited from log4cxx::spi::Configurator
 Configurator ()
 

Static Protected Member Functions

static LogString getAttribute (log4cxx::helpers::CharsetDecoderPtr &utf8Decoder, apr_xml_elem *, const std::string &attrName)
 

Detailed Description

Use this class to initialize the log4cxx environment using a DOM tree.

Sometimes it is useful to see how log4cxx is reading configuration files. You can enable log4cxx internal logging by setting the debug attribute in the log4cxx element. As in

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

There are sample XML files included in the package.

Member Typedef Documentation

◆ AppenderMap

Constructor & Destructor Documentation

◆ ~DOMConfigurator()

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

◆ DOMConfigurator() [1/2]

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

◆ DOMConfigurator() [2/2]

log4cxx::xml::DOMConfigurator::DOMConfigurator ( log4cxx::helpers::Pool p)

Member Function Documentation

◆ configure() [1/7]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configure ( const CFStringRef filename)
static

A static version of doConfigure.

◆ configure() [2/7]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configure ( const char *  filename)
inlinestatic

A static version of doConfigure.

◆ configure() [3/7]

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

Read configuration options from configFilename.

Stores Logger instances in the spi::LoggerRepository held by LogManager.

◆ configure() [4/7]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configure ( const std::basic_string< UniChar > &  filename)
static

A static version of doConfigure.

◆ configure() [5/7]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configure ( const std::string &  filename)
static

A static version of doConfigure.

◆ configure() [6/7]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configure ( const std::wstring &  filename)
static

A static version of doConfigure.

◆ configure() [7/7]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configure ( const wchar_t *  filename)
inlinestatic

A static version of doConfigure.

◆ configureAndWatch() [1/9]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configureAndWatch ( const CFStringRef configFilename)
static

Like configureAndWatch(const File& filename, long delay) except that the default delay as defined by log4cxx::helpers::FileWatchdog::DEFAULT_DELAY is used.

Parameters
configFilenameA configuration file in XML format.

◆ configureAndWatch() [2/9]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configureAndWatch ( const CFStringRef configFilename,
long  delay 
)
static

◆ configureAndWatch() [3/9]

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

Read configuration options from configFilename (if it exists).

A thread 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 thread will be stopped by a LogManager::shutdown call.

Parameters
configFilenameA XML format file.
delayThe delay in milliseconds to wait between each check.

◆ configureAndWatch() [4/9]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configureAndWatch ( const std::basic_string< UniChar > &  configFilename)
static

Like configureAndWatch(const File& filename, long delay) except that the default delay as defined by log4cxx::helpers::FileWatchdog::DEFAULT_DELAY is used.

Parameters
configFilenameA configuration file in XML format.

◆ configureAndWatch() [5/9]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configureAndWatch ( const std::basic_string< UniChar > &  configFilename,
long  delay 
)
static

◆ configureAndWatch() [6/9]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configureAndWatch ( const std::string &  configFilename)
static

Like configureAndWatch(const File& filename, long delay) except that the default delay as defined by log4cxx::helpers::FileWatchdog::DEFAULT_DELAY is used.

Parameters
configFilenameA configuration file in XML format.

◆ configureAndWatch() [7/9]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configureAndWatch ( const std::string &  configFilename,
long  delay 
)
static

Read the configuration file configFilename if it exists.

Moreover, a thread will be created that will periodically check if configFilename has been created or modified. The period is determined by the delay argument. If a change or file creation is detected, then configFilename is read to configure log4cxx.

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

Parameters
configFilenameA configuration file in XML format.
delayThe delay in milliseconds to wait between each check.

◆ configureAndWatch() [8/9]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configureAndWatch ( const std::wstring &  configFilename)
static

Like configureAndWatch(const File& filename, long delay) except that the default delay as defined by log4cxx::helpers::FileWatchdog::DEFAULT_DELAY is used.

Parameters
configFilenameA configuration file in XML format.

◆ configureAndWatch() [9/9]

static spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::configureAndWatch ( const std::wstring &  configFilename,
long  delay 
)
static

◆ doConfigure()

spi::ConfigurationStatus log4cxx::xml::DOMConfigurator::doConfigure ( const File filename,
spi::LoggerRepositoryPtr  repository 
)
overridevirtual

Interpret filename as an XML file and set up Log4cxx accordingly.

If repository 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
filenameThe file to parse.
repositoryWhere the Logger instances reside.

Implements log4cxx::spi::Configurator.

◆ findAppenderByName()

AppenderPtr log4cxx::xml::DOMConfigurator::findAppenderByName ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  elem,
apr_xml_doc *  doc,
const LogString appenderName,
AppenderMap appenders 
)
protected

Used internally to parse appenders by IDREF name.

◆ findAppenderByReference()

AppenderPtr log4cxx::xml::DOMConfigurator::findAppenderByReference ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  appenderRef,
apr_xml_doc *  doc,
AppenderMap appenders 
)
protected

Used internally to parse appenders by IDREF element.

◆ getAttribute()

static LogString log4cxx::xml::DOMConfigurator::getAttribute ( log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  ,
const std::string &  attrName 
)
staticprotected

◆ parse()

void log4cxx::xml::DOMConfigurator::parse ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  element,
apr_xml_doc *  doc,
AppenderMap appenders 
)
protected

Used internally to configure the log4cxx framework from an in-memory representation of an XML document.

◆ parseAppender()

AppenderPtr log4cxx::xml::DOMConfigurator::parseAppender ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  appenderElement,
apr_xml_doc *  doc,
AppenderMap appenders 
)
protected

Used internally to parse an appender element.

◆ parseChildrenOfLoggerElement()

void log4cxx::xml::DOMConfigurator::parseChildrenOfLoggerElement ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  catElement,
LoggerPtr  logger,
bool  isRoot,
apr_xml_doc *  doc,
AppenderMap appenders 
)
protected

Used internally to parse the children of a logger element.

◆ parseErrorHandler()

void log4cxx::xml::DOMConfigurator::parseErrorHandler ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  element,
AppenderPtr appender,
apr_xml_doc *  doc,
AppenderMap appenders 
)
protected

Used internally to parse an ErrorHandler element.

◆ parseFilters()

void log4cxx::xml::DOMConfigurator::parseFilters ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  element,
std::vector< log4cxx::spi::FilterPtr > &  filters 
)
protected

Used internally to parse a filter element.

◆ parseLayout()

LayoutPtr log4cxx::xml::DOMConfigurator::parseLayout ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  layout_element 
)
protected

Used internally to parse a layout element.

◆ parseLevel()

void log4cxx::xml::DOMConfigurator::parseLevel ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  element,
LoggerPtr  logger,
bool  isRoot 
)
protected

Used internally to parse a level element.

◆ parseLogger()

void log4cxx::xml::DOMConfigurator::parseLogger ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  loggerElement,
apr_xml_doc *  doc,
AppenderMap appenders 
)
protected

Used internally to parse a logger element.

◆ parseLoggerFactory()

void log4cxx::xml::DOMConfigurator::parseLoggerFactory ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  factoryElement 
)
protected

Used internally to parse the logger factory element.

◆ parseRollingPolicy()

log4cxx::rolling::RollingPolicyPtr log4cxx::xml::DOMConfigurator::parseRollingPolicy ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  factoryElement 
)
protected

Used internally to parse the logger factory element.

◆ parseRoot()

void log4cxx::xml::DOMConfigurator::parseRoot ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  rootElement,
apr_xml_doc *  doc,
AppenderMap appenders 
)
protected

Used internally to parse the root logger element.

◆ parseTriggeringPolicy()

log4cxx::helpers::ObjectPtr log4cxx::xml::DOMConfigurator::parseTriggeringPolicy ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  factoryElement 
)
protected

Used internally to parse the logger factory element.

◆ setParameter()

void log4cxx::xml::DOMConfigurator::setParameter ( log4cxx::helpers::Pool p,
log4cxx::helpers::CharsetDecoderPtr &  utf8Decoder,
apr_xml_elem *  elem,
log4cxx::config::PropertySetter propSetter 
)
protected

◆ subst()

LogString log4cxx::xml::DOMConfigurator::subst ( const LogString value)
protected

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