Modified: logging/log4php/branches/experimental/config-adapters/src/site/xdoc/docs/appenders/console.xml URL: http://svn.apache.org/viewvc/logging/log4php/branches/experimental/config-adapters/src/site/xdoc/docs/appenders/console.xml?rev=1182331&r1=1182330&r2=1182331&view=diff ============================================================================== --- logging/log4php/branches/experimental/config-adapters/src/site/xdoc/docs/appenders/console.xml (original) +++ logging/log4php/branches/experimental/config-adapters/src/site/xdoc/docs/appenders/console.xml Wed Oct 12 12:33:23 2011 @@ -25,8 +25,8 @@
-

LoggerAppenderConsole writes logging events to the stdout (php://stdout) or - the stderr (php://stderr) stream, the former being the default target.

+

LoggerAppenderConsole writes logging events to the php://stdout or + the php://stderr stream, the former being the default target.

The following options are available:

@@ -44,7 +44,7 @@ string No stdout - The stream to write to, "stdout" or "stderr". + The stream to write to; either "stdout" or "stderr". Modified: logging/log4php/branches/experimental/config-adapters/src/site/xdoc/docs/configuration.xml URL: http://svn.apache.org/viewvc/logging/log4php/branches/experimental/config-adapters/src/site/xdoc/docs/configuration.xml?rev=1182331&r1=1182330&r2=1182331&view=diff ============================================================================== --- logging/log4php/branches/experimental/config-adapters/src/site/xdoc/docs/configuration.xml (original) +++ logging/log4php/branches/experimental/config-adapters/src/site/xdoc/docs/configuration.xml Wed Oct 12 12:33:23 2011 @@ -28,25 +28,23 @@

Apache log4php can be configured either programatically or with a file containing the configuration parameters in one of the supported formats.

-

The configuration should be provided by calling Logger::configure(...) method before any logging - is done. Otherwise, the default configuration will be used.

- - - -

If no configuration

+

The configuration should be provided by calling Logger::configure() method before any logging + is done. Otherwise, the default configuration will be used.

+ - - - +

XML is the most common configuration format, and it is the most prominently featured in the + documentation and examples.

+ +
- + -

Configuration is stored in a PHP array. This is the format used internally by log4php and other - formats are converted to a PHP array before being used. Because of this, the PHP format should be - used when performance is important.

+

Configuration can also be stored in a PHP array. This is the format used internally by log4php. Other + formats are converted to a PHP array before being used. Because of this, the PHP configuration format + should be used when performance is important.

It is possible to pass an configuration array directly to Logger::configure().

@@ -90,20 +88,100 @@ return array(
Logger::configure('config.php');
-

Hint: to translate a XML or properties configuration file to PHP, run the following code:

+
+

Hint: to translate a XML or properties configuration file to PHP, run the following code:

+
Logger::configure('config.php');
+
+
+ + + + +

The properties configuration format is a legacy method of configuring log4php. It was inherited from + Apache log4j and uses the same format. The only + difference is that lines begin with log4php instead of log4j.

+ +
+

This format has been deprecated and will not be updated + to include newly introduced features in the future. It is recommended that you use either the XML or PHP + configuration format.

-
Logger::configure('config.php');
+

The properites configuration format does not support filters.

+

The following is a high level overview of all options provided by this format:

- + +
+# Appender named "default"
+log4php.appender.default = LoggerAppenderEcho
+log4php.appender.default.layout = LoggerLayoutTTCC
+
+# Appender named "file"
+log4php.appender.file = LoggerAppenderDailyFile
+log4php.appender.file.layout = LoggerLayoutPattern
+log4php.appender.file.layout.conversionPattern = %d{ISO8601} [%p] %c: %m (at %F line %L)%n
+log4php.appender.file.datePattern = Ymd
+log4php.appender.file.file = target/examples/daily_%s.log
+log4php.appender.file.threshold = warn
+
+# Root logger, linked to "default" appender
+log4php.rootLogger = DEBUG, default
+
+# Logger named "foo", linked to "default" appender
+log4php.logger.foo = warn, default
+
+# Logger named "foo.bar", linked to "file" appender
+log4php.logger.foo.bar = debug, file
+log4php.additivity.foo.bar = true
+
+# Logger named "foo.bar.baz", linked to both "file" and "default" appenders
+log4php.logger.foo.bar.baz = trace, default, file
+log4php.additivity.foo.bar.baz = false
+
+# Renderers for Fruit and Beer classes
+log4php.renderer.Fruit = FruitRenderer
+log4php.renderer.Beer = BeerRenderer
+
+# Setting base threshold
+log4php.threshold = debug
+
+ +

If no configuration is provided before the initial logging request is issued, log4php will configure + using the default configuration. This consists of a single LoggerAppenderEcho appender, + using LoggerLayoutTTCC, attached to the root logger and set to the DEBUG level.

+ +

The default configuration in PHP format is:

+ +
+array(
+    'rootLogger' => array(
+        'appenders' => array('default'),
+    ),
+    'appenders' => array(
+        'default' => array(
+            'class' => 'LoggerAppenderConsole',
+            'layout' => array(
+                'class' => 'LoggerLayoutSimple'
+            )
+        )
+    )
+)
+
- +
+

Hint: You can fetch the default configuration as a PHP array by running:

+
LoggerConfigurator::getDefaultConfiguration();
+
+
+ + +

It is possible to configure log4php fully programmatically.

+
-
Added: logging/log4php/branches/experimental/config-adapters/src/site/xdoc/docs/filters.xml URL: http://svn.apache.org/viewvc/logging/log4php/branches/experimental/config-adapters/src/site/xdoc/docs/filters.xml?rev=1182331&view=auto ============================================================================== --- logging/log4php/branches/experimental/config-adapters/src/site/xdoc/docs/filters.xml (added) +++ logging/log4php/branches/experimental/config-adapters/src/site/xdoc/docs/filters.xml Wed Oct 12 12:33:23 2011 @@ -0,0 +1,317 @@ + + + + + + Filters + + + +
+ +

Filtering is a mechanism which allows the user to configure more precisely which logging events will be + logged by an appender, and which will be ignored.

+ +

Multiple filters can be defined on any appender; they will form a filter chain. When a logging event is + passed onto an appender, the event will first pass through the filter chain. Each filter in the chain will + examine the logging event and make a decision to either:

+ +
    +
  1. ACCEPT the logging event - The event will be logged without consulting the + remaining filters in the chain.
  2. +
  3. DENY the logging event - The event will be not logged without consulting the + remaining filters in the chain.
  4. +
  5. Remain NEUTRAL - No decision is made, therefore the next filter in the chain is + consulted. If there are no remaining filters in the chain, the event is logged.
  6. +
+ + + +

Filters are configurable in the XML and PHP configuration format. They cannot be configured using + the properties configuration format.

+ +

Like appenders and layouts, depending on the class used, filters may have configurable parameters + which determine their behaviour.

+ +

Here is an XML configuration example:

+ +

+    
+        
+        
+            
+            
+        
+        
+            
+            
+        
+    
+    
+        
+        
+    
+
+]]>
+ +

And the same configuration in PHP format:

+ +
 array(
+        'default' => array(
+            'class' => 'LoggerAppenderEcho'
+            'layout' => array(
+                'class' => 'LoggerLayoutSimple'
+            ),
+            'filters' => array(
+                array(
+                    'class' => 'LoggerFilterStringMatch',
+                    'params' => array(
+                        'stringToMatch' => 'interesting',
+                        'acceptOnMatch' => true,
+                    )
+                ),
+                array(
+                    'class' => 'LoggerFilterLevelRange',
+                    'params' => array(
+                        'levelMin' => 'debug',
+                        'levelMax' => 'error',
+                    )
+                )
+            )
+        )
+    ),
+    'rootLogger' => array(
+    	'appenders' => array('default'),
+    )
+)
+]]>
+ + +

In this example, there are two filters defined for the default appender.

+ +

The first filter LoggerFilterStringMatch searches for the string "interesting" in the + logging event's message. If the string is found, the filter will ACCEPT the logging event, and the + event will be logged. If the string is not found, the filter will remain NEUTRAL, and the event will be + passed on to the next filter.

+ +

The second filter LoggerFilterLevelRange ACCEPTS all events which have a level between + DEBUG and ERROR (in other words, levels DEBUG, INFO, WARN and ERROR). It DENIES all other events.

+ +

Therefore, this filter configuration will log events which which have a level between DEBUG and + ERROR, except of theose which have the string "interesting" in the message. Those will be logged + regardless of their level.

+ +
+ + + +

The following filters are available in log4php:

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
NameDestination
LoggerFilterDenyAllDenies all logging events.
LoggerFilterLevelMatchFilters based on logging event level.
LoggerFilterLevelRangeFilters based on logging event level range.
LoggerFilterStringMatchFilters by searching for a string in the logging event message.
+
+ + + +

This filters simply denies all logging events. It has no configurable parameters.

+
+ + +

This filter either accepts the specified logger level or denies it.

+ +

Configurable options

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
OptionTypeRequiredDefaultDescription
levelToMatchLoggerLevelYes-The level to match
acceptOnMatchbooleanNotrueIf true, the matching log level is accepted, denied otherwise.
+ +

Example

+ +

The following filter configuration will deny all logging events with level DEBUG. It will remain + neutral for others.

+ +

+    
+    
+
+]]>
+ +
+ + +

This filter accepts or denies logging events if their log level is within the specified range.

+ +

Configurable options

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OptionTypeRequiredDefaultDescription
levelMinLoggerLevelYes-The minimum level to log. If set, levels lower than this will be denied.
levelMaxLoggerLevelYes-The maximum level to log. If set, levels higher than this will be denied.
acceptOnMatchbooleanNotrueIf true, the matching log level is accepted, denied otherwise.
+ +

Example

+ +

The following filter configuration denies levels greater than WARN.

+ +

+    
+    
+
+]]>
+ +
+ + +

This filter allows or denies logging events if their message contains a given string.

+ +

Configurable options

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
OptionTypeRequiredDefaultDescription
stringToMatchLoggerLevelYes-The level to match
levelMaxLoggerLevelYes-The level to match
acceptOnMatchbooleanNotrueIf true, the matching log level is accepted, denied otherwise.
+ +

Example

+ +

The following filter configuration denies events which contain the string "not-interesting" in + their message.

+ +

+    
+    
+
+]]>
+ +
+
+ +
Added: logging/log4php/branches/experimental/config-adapters/src/site/xdoc/install.xml URL: http://svn.apache.org/viewvc/logging/log4php/branches/experimental/config-adapters/src/site/xdoc/install.xml?rev=1182331&view=auto ============================================================================== --- logging/log4php/branches/experimental/config-adapters/src/site/xdoc/install.xml (added) +++ logging/log4php/branches/experimental/config-adapters/src/site/xdoc/install.xml Wed Oct 12 12:33:23 2011 @@ -0,0 +1,65 @@ + + + + + + Installing + + + +
+ + + +

Download the latest source package from the download page and unpack it.

+ +

The package directory structure is as follows:

+ +
+├───apidocs      - API generated documentation
+└───src
+    ├───assembly - Maven assembly configuration 
+    ├───changes  - The change log
+    ├───examples - Various usage examples
+    ├───main  
+    │   └───php  - The main source code
+    ├───site     - Web site source
+    └───test     - Unit tests
+
+

Most users will primarily be interested in the source code which is located in + /src/main/php. The contents of this directory may be copied to a directory within your + project for easier access.

+ +
+ + + +

Apache log4php has it's own PEAR channel.

+ +

To install from the PEAR channel, execute the following commands:

+ +
+pear channel-discover pear.apache.org/log4php
+pear install log4php/Apache_log4php
+
+ +
+
+ +
Added: logging/log4php/branches/experimental/config-adapters/src/site/xdoc/privacy.xml URL: http://svn.apache.org/viewvc/logging/log4php/branches/experimental/config-adapters/src/site/xdoc/privacy.xml?rev=1182331&view=auto ============================================================================== --- logging/log4php/branches/experimental/config-adapters/src/site/xdoc/privacy.xml (added) +++ logging/log4php/branches/experimental/config-adapters/src/site/xdoc/privacy.xml Wed Oct 12 12:33:23 2011 @@ -0,0 +1,53 @@ + + + + + + Privacy policy + + + +
+

Information about your use of this web site is collected using server access logs and a tracking cookie. + The collected information consists of the following:

+ + + +

Part of this information is gathered using a tracking cookie set by the + Google Analytics service + and handled by Google as described in their + privacy policy. + See your browser documentation for instructions on how to disable the cookie if you prefer not to share + this data with Google.

+ +

We use the gathered information to help us make our site more useful to visitors and to better understand how + and when our site is used. We do not track or collect personally identifiable information or associate gathered + data with any personally identifying information from other sources.

+ +

By using this web site, you consent to the collection of this data in the manner and for the purpose described + above.

+
+ +
Modified: logging/log4php/branches/experimental/config-adapters/src/site/xdoc/quickstart.xml URL: http://svn.apache.org/viewvc/logging/log4php/branches/experimental/config-adapters/src/site/xdoc/quickstart.xml?rev=1182331&r1=1182330&r2=1182331&view=diff ============================================================================== --- logging/log4php/branches/experimental/config-adapters/src/site/xdoc/quickstart.xml (original) +++ logging/log4php/branches/experimental/config-adapters/src/site/xdoc/quickstart.xml Wed Oct 12 12:33:23 2011 @@ -112,9 +112,94 @@ WARN - My fourth message. ERROR - My fifth message. FATAL - My sixth message. ]]> + + + + +

This example covers named loggers, layouts and best practices in object-oriented programming.

+ +

Create a configuration file named log4php.xml with the following content:

+ +

+
+
+    
+    
+    
+        
+        
+    
+
+    
+        
+    
+    
+    
+        
+        
+    
+
+]]>
+ +

The configuration defines two appenders: one writes to the console, and the other to a file.

+ +

The + console appender doesn't have a layout defined, so it will revert to default layout + (LoggerLayoutSimple). The + file appender uses a different layout + (LoggerLayoutTTCC) + which will result in different formatting of the logging + events.

+ +

The console appender is linked to the root logger. The file appender is linked to the logger named + Foo, however Foo also inherits appenders from the root logger (in this case + the console appender). This means that logging events sent to the Foo logger will be + logged both to the console and the file.

+

Consider the following code snippet:

+ +
log = Logger::getLogger(__CLASS__);
+    }
+
+    /** Logger can be used from any member method. */
+    public function go()
+    {
+        $this->log->info("We have liftoff.");
+    }
+}
+
+$foo = new Foo();
+$foo->go();
+]]>
+ +

This produces the following output in the console:

+
INFO - We have liftoff.
+ +

And the following in the log file:

+
01/06/11 18:43:39,545 [5428] INFO Foo - We have liftoff.
+

Note the different layout, this is because LoggerLayoutTTCC was used as layout for the file appender.

+