Class LoggerConfiguratorXml

Description

Implements interfaces:

Use this class to initialize the log4php environment using XML files.

Read the log4php.dtd included in the documentation directory. Note that php parser does not validate the document.

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

An example for this configurator:

  1. require_once dirname(__FILE__).'/../../main/php/Logger.php';
  2.  
  3. Logger::configure(dirname(__FILE__).'/../resources/configurator_xml.xml');
  4. $logger Logger::getRootLogger();
  5. $logger->info("Hello World!");

The corresponding XML file:

  1. <log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/"
  2.     threshold="all" debug="false">
  3.     <appender name="default" class="LoggerAppenderEcho">
  4.         <layout class="LoggerLayoutTTCC" />
  5.     </appender>
  6.     <root>
  7.         <level value="DEBUG" />
  8.         <appender_ref ref="default" />
  9.     </root>
  10. </log4php:configuration>
There are more sample XML files included in the package under tests/ subdirectories.

  • version: $Revision: 883108 $
  • since: 0.4

Located in /configurators/LoggerConfiguratorXml.php (line 46)


	
			
Class Constant Summary
 DEFAULT_CONFIGURATION = '<?xml version="1.0" ?> <log4php:configuration threshold="all"> <appender name="A1" class="LoggerAppenderEcho"> <layout class="LoggerLayoutSimple" /> </appender> <root> <level value="debug" /> <appender_ref ref="A1" /> </root> </log4php:configuration>'
 DEFAULT_FILENAME = './log4php.xml'
 FILTER_STATE = 1040
 LAYOUT_STATE = 1010
 LOGGER_STATE = 1030
 ROOT_STATE = 1020
 XMLNS = 'HTTP://LOGGING.APACHE.ORG/LOG4PHP/'
Method Summary
static void configure (LoggerHierarchy $hierarchy, [string $url = ''])
LoggerConfiguratorXml __construct ()
Methods
static configure (line 125)

Configure the default repository using the resource pointed by url.

Url is any valid resource as defined in http://www.php.net/file function. Note that the resource will be search with use_include_path parameter set to "1".

  • access: public
static void configure (LoggerHierarchy $hierarchy, [string $url = ''])

Implementation of:
LoggerConfigurator::configure()
Interpret a resource pointed by a url and configure accordingly.
Constructor __construct (line 108)

Constructor

  • access: public
LoggerConfiguratorXml __construct ()
Class Constants
APPENDER_STATE = 1000 (line 47)
DEFAULT_CONFIGURATION =
'<?xml version="1.0" ?>
<log4php:configuration threshold="all">
<appender name="A1" class="LoggerAppenderEcho">
<layout class="LoggerLayoutSimple" />
</appender>
<root>
<level value="debug" />
<appender_ref ref="A1" />
</root>
</log4php:configuration>'
(line 58)
  • var: the default configuration document
DEFAULT_FILENAME = './log4php.xml' (line 53)
FILTER_STATE = 1040 (line 51)
LAYOUT_STATE = 1010 (line 48)
LOGGER_STATE = 1030 (line 50)
ROOT_STATE = 1020 (line 49)
XMLNS = 'HTTP://LOGGING.APACHE.ORG/LOG4PHP/' (line 73)
  • var: the elements namespace

Documentation generated on Fri, 27 Nov 2009 07:44:49 +0100 by phpDocumentor 1.4.3