logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ihabu...@apache.org
Subject svn commit: r1182331 [4/4] - in /logging/log4php/branches/experimental/config-adapters/src/site: ./ apt/ apt/docs/ resources/css/ resources/js/ resources/libs/ xdoc/ xdoc/docs/ xdoc/docs/appenders/
Date Wed, 12 Oct 2011 12:33:24 GMT
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 @@
 	<body>
 		<section name="LoggerAppenderConsole">
 		
-			<p><code>LoggerAppenderConsole</code> writes logging events to the stdout
(<code>php://stdout</code>) or 
-			the stderr (php://stderr) stream, the former being the default target.</p>
+			<p><code>LoggerAppenderConsole</code> writes logging events to the <code>php://stdout</code>
or 
+			the <code>php://stderr</code> stream, the former being the default target.</p>
 			
 			<subsection name="Options">
 				<p>The following options are available:</p>
@@ -44,7 +44,7 @@
 						<td>string</td>
 						<td>No</td>
 						<td>stdout</td>
-						<td>The stream to write to, "stdout" or "stderr".</td>
+						<td>The stream to write to; either "stdout" or "stderr".</td>
 					</tr>
 				</table>
 				

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 @@
 			<p>Apache log4php can be configured either programatically or with a file containing
the configuration 
 			parameters in one of the supported formats.</p>
 			
-			<p>The configuration should be provided by calling <code>Logger::configure(...)</code>
method before any logging 
-			is done. Otherwise, the default configuration will be used.</p>
-			
-			<subsection name="Default configuration">
-				
-				<p>If no configuration </p>
+			<p>The configuration should be provided by calling <code>Logger::configure()</code>
method before any logging 
+			is done. Otherwise, the <a href="#Default_configuration">default configuration</a>
will be used.</p>
 			
+			<subsection name="XML" id="XML">
 			
-			</subsection>
-			
-			<subsection name="XML">
+				<p>XML is the most common configuration format, and it is the most prominently
featured in the 
+				documentation and examples.</p>
+				
+				
 			
 			</subsection>
 			
-			<subsection name="PHP">
+			<subsection name="PHP" id="PHP">
 			
-				<p>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.</p>
+				<p>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.</p>
 				
 				<p>It is possible to pass an configuration array directly to <code>Logger::configure()</code>.</p>
 
@@ -90,20 +88,100 @@ return array(
 				
 				<pre class="prettyprint">Logger::configure('config.php');</pre>
 				
-				<p>Hint: to translate a XML or properties configuration file to PHP, run the following
code:</p>
+				<div class="alert-message block-message info">
+					<p><strong>Hint:</strong> to translate a XML or properties configuration
file to PHP, run the following code:</p>
+					<pre>Logger::configure('config.php');</pre>
+				</div>
+			</subsection>
+
+
+			<subsection name="Properties (INI)" id="INI">
+
+				<p>The properties configuration format is a legacy method of configuring log4php.
It was inherited from 
+				<a href="logging.apache.org/log4j/1.2/manual.html">Apache log4j</a> and uses
the same format. The only 
+				difference is that lines begin with <code>log4php</code> instead of <code>log4j</code>.</p>
+				
+				<div class="alert-message block-message warning">
+					<p>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 <a href="#XML">XML</a> or <a href="PHP">PHP</a> 
+				configuration format.</p></div>
 				
-				<pre class="prettyprint">Logger::configure('config.php');</pre>
+				<p>The properites configuration format does not support filters.</p>
 				
+				<p>The following is a high level overview of all options provided by this format:</p>
 				
-			
+				
+<pre class="prettyprint">
+# 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
+</pre>
 			</subsection>
 
+			<subsection name="Default configuration" id="Default_configuration">
+				<p>If no configuration is provided before the initial logging request is issued,
log4php will configure
+				using the default configuration. This consists of a single <code>LoggerAppenderEcho</code>
appender,
+				using <code>LoggerLayoutTTCC</code>, attached to the root logger and set
to the DEBUG level.</p>
+				
+				<p>The default configuration in PHP format is:</p>
+				
+<pre class="prettyprint">
+array(
+    'rootLogger' => array(
+        'appenders' => array('default'),
+    ),
+    'appenders' => array(
+        'default' => array(
+            'class' => 'LoggerAppenderConsole',
+            'layout' => array(
+                'class' => 'LoggerLayoutSimple'
+            )
+        )
+    )
+)
+</pre>
 
-			<subsection name="Properties (INI)">
+				<div class="alert-message block-message info">
+					<p><strong>Hint:</strong> You can fetch the default configuration
as a PHP array by running:</p>
+					<pre class="prettyprint">LoggerConfigurator::getDefaultConfiguration();</pre>
+				</div>
+			</subsection>
 			
+			<subsection name="Programmatic configuration">
+				
+				<p>It is possible to configure log4php fully programmatically.</p>
+				
 			</subsection>
 
-			
 
 		</section>
 	</body>

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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ 
+         http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
+
+	<properties>
+		<title>Filters</title>
+	</properties>
+
+	<body>
+		<section name="Filters">
+		
+			<p>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.</p>
+
+			<p>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:</p>
+			
+			<ol type="a">
+				<li><strong>ACCEPT</strong> the logging event - The event will be logged
without consulting the 
+				remaining filters in the chain.</li>
+				<li><strong>DENY</strong> the logging event - The event will be not
logged without consulting the 
+				remaining filters in the chain.</li>
+				<li>Remain <strong>NEUTRAL</strong> - 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.</li>
+			</ol>
+			
+			<subsection name="Configuring">
+			
+				<p>Filters are configurable in the XML and PHP configuration format. They cannot
be configured using
+				the properties configuration format.</p>
+				
+				<p>Like appenders and layouts, depending on the class used, filters may have configurable
parameters 
+				which determine their behaviour.</p>
+			
+				<p>Here is an XML configuration example:</p>
+				
+<pre class="prettyprint linenums"><![CDATA[
+<configuration xmlns="http://logging.apache.org/log4php/">
+    <appender name="defualt" class="LoggerAppenderEcho">
+        <layout class="LoggerLayoutSimple"/>
+        <filter class="LoggerFilterStringMatch">
+            <param name="stringToMatch" value="interesting" />
+            <param name="acceptOnMatch" value="true" />
+        </filter>
+        <filter class="LoggerFilterLevelRange">
+            <param name="levelMin" value="debug" />
+            <param name="levelMax" value="error" />
+        </filter>
+    </appender>
+    <root>
+        <level value="TRACE" />
+        <appender_ref ref="defualt" />
+    </root>
+</configuration>
+]]></pre>
+
+				<p>And the same configuration in PHP format:</p>
+				
+<pre class="prettyprint linenums"><![CDATA[
+array(
+    'appenders' => 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'),
+    )
+)
+]]></pre>	
+				
+				
+				<p>In this example, there are two filters defined for the <em>default</em>
appender.</p>
+				
+				<p>The first filter <code>LoggerFilterStringMatch</code> 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.</p>
+				
+				<p>The second filter <code>LoggerFilterLevelRange</code> 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.</p>
+				
+				<p>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.</p>
+			
+			</subsection>
+			
+			<subsection name="Filter reference">
+			
+				<p>The following filters are available in log4php:</p>
+				
+				<table>
+					<thead>
+						<tr>
+							<th>Name</th>
+							<th>Destination</th>
+						</tr>
+					</thead>
+					<tbody>
+						<tr>
+							<td><a href="#LoggerFilterDenyAll">LoggerFilterDenyAll</a></td>
+							<td>Denies all logging events.</td>
+						</tr>
+						<tr>
+							<td><a href="#LoggerFilterLevelMatch">LoggerFilterLevelMatch</a></td>
+							<td>Filters based on logging event level.</td>
+						</tr>
+						<tr>
+							<td><a href="#LoggerFilterLevelRange">LoggerFilterLevelRange</a></td>
+							<td>Filters based on logging event level range.</td>
+						</tr>
+						<tr>
+							<td><a href="#LoggerFilterStringMatch">LoggerFilterStringMatch</a></td>
+							<td>Filters by searching for a string in the logging event message.</td>
+						</tr>
+					</tbody>
+				</table>
+			</subsection>
+			
+			
+			<subsection name="LoggerFilterDenyAll" id="LoggerFilterDenyAll">
+				<p>This filters simply denies all logging events. It has no configurable parameters.</p>
+			</subsection>
+			
+			<subsection name="LoggerFilterLevelMatch" id="LoggerFilterLevelMatch">
+				<p>This filter either accepts the specified logger level or denies it.</p>
+				
+				<h4>Configurable options</h4>
+				
+				<table>
+					<thead>
+						<tr>
+							<th>Option</th>
+							<th>Type</th>
+							<th>Required</th>
+							<th>Default</th>
+							<th>Description</th>
+						</tr>
+					</thead>
+					<tbody>
+						<tr>
+							<td>levelToMatch</td>
+							<td>LoggerLevel</td>
+							<td><strong>Yes</strong></td>
+							<td>-</td>
+							<td>The level to match</td>
+						</tr>
+						<tr>
+							<td>acceptOnMatch</td>
+							<td>boolean</td>
+							<td>No</td>
+							<td>true</td>
+							<td>If true, the matching log level is accepted, denied otherwise.</td>
+						</tr>
+					</tbody>
+				</table>
+				
+				<h4>Example</h4>
+				
+				<p>The following filter configuration will deny all logging events with level DEBUG.
It will remain 
+				neutral for others.</p>
+				
+<pre class="prettyprint linenums"><![CDATA[
+<filter class="LoggerFilterLevelMatch">
+    <param name="levelToMatch" value="debug" />
+    <param name="acceptOnMatch" value="false" />
+</filter>
+]]></pre>
+				
+			</subsection>
+			
+			<subsection name="LoggerFilterLevelRange" id="LoggerFilterLevelRange">
+				<p>This filter accepts or denies logging events if their log level is within the
specified range.</p>
+				
+				<h4>Configurable options</h4>
+				
+				<table>
+					<thead>
+						<tr>
+							<th>Option</th>
+							<th>Type</th>
+							<th>Required</th>
+							<th>Default</th>
+							<th>Description</th>
+						</tr>
+					</thead>
+					<tbody>
+						<tr>
+							<td>levelMin</td>
+							<td>LoggerLevel</td>
+							<td><strong>Yes</strong></td>
+							<td>-</td>
+							<td>The minimum level to log. If set, levels lower than this will be denied.</td>
+						</tr>
+						<tr>
+							<td>levelMax</td>
+							<td>LoggerLevel</td>
+							<td><strong>Yes</strong></td>
+							<td>-</td>
+							<td>The maximum level to log. If set, levels higher than this will be denied.</td>
+						</tr>
+						<tr>
+							<td>acceptOnMatch</td>
+							<td>boolean</td>
+							<td>No</td>
+							<td>true</td>
+							<td>If true, the matching log level is accepted, denied otherwise.</td>
+						</tr>
+					</tbody>
+				</table>
+				
+				<h4>Example</h4>
+				
+				<p>The following filter configuration denies levels greater than WARN.</p>
+				
+<pre class="prettyprint linenums"><![CDATA[
+<filter class="LoggerFilterLevelRange">
+    <param name="levelMax" value="warn" />
+    <param name="acceptOnMatch" value="false" />
+</filter>
+]]></pre>
+				
+			</subsection>
+			
+			<subsection name="LoggerFilterStringMatch" id="LoggerFilterStringMatch">
+				<p>This filter allows or denies logging events if their message contains a given
string.</p>
+				
+				<h4>Configurable options</h4>
+				
+				<table>
+					<thead>
+						<tr>
+							<th>Option</th>
+							<th>Type</th>
+							<th>Required</th>
+							<th>Default</th>
+							<th>Description</th>
+						</tr>
+					</thead>
+					<tbody>
+						<tr>
+							<td>stringToMatch</td>
+							<td>LoggerLevel</td>
+							<td><strong>Yes</strong></td>
+							<td>-</td>
+							<td>The level to match</td>
+						</tr>
+						<tr>
+							<td>levelMax</td>
+							<td>LoggerLevel</td>
+							<td><strong>Yes</strong></td>
+							<td>-</td>
+							<td>The level to match</td>
+						</tr>
+						<tr>
+							<td>acceptOnMatch</td>
+							<td>boolean</td>
+							<td>No</td>
+							<td>true</td>
+							<td>If true, the matching log level is accepted, denied otherwise.</td>
+						</tr>
+					</tbody>
+				</table>
+				
+				<h4>Example</h4>
+				
+				<p>The following filter configuration denies events which contain the string "not-interesting"
in 
+				their message.</p>
+				
+<pre class="prettyprint linenums"><![CDATA[
+<filter class="LoggerFilterStringMatch">
+    <param name="StringToMatch" value="not-interesting" />
+    <param name="AcceptOnMatch" value="false" />
+</filter>
+]]></pre>
+				
+			</subsection>
+		</section>
+	</body>
+</document>

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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ 
+         http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
+
+	<properties>
+		<title>Installing</title>
+	</properties>
+
+	<body>
+		<section name="Installing">
+		
+			<subsection name="From source package">
+			
+				<p>Download the latest source package from the <a href="download.html">download
page</a> and unpack it.</p>
+			
+				<p>The package directory structure is as follows:</p>
+			
+<pre>
+├───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
+</pre>
+				<p>Most users will primarily be interested in the source code which is located
in 
+				<code>/src/main/php</code>. The contents of this directory may be copied
to a directory within your 
+				project for easier access.</p>
+			
+			</subsection>
+			
+			<subsection name="From PEAR repository">
+			
+				<p>Apache log4php has it's own <a href="http://pear.apache.org/log4php/index.html">PEAR
channel</a>.</p>
+				
+				<p>To install from the PEAR channel, execute the following commands:</p>
+			
+<pre>
+pear channel-discover pear.apache.org/log4php
+pear install log4php/Apache_log4php
+</pre>
+				
+			</subsection>
+		</section>
+	</body>
+</document>

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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ 
+         http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
+
+	<properties>
+		<title>Privacy policy</title>
+	</properties>
+
+	<body>
+		<section name="Privacy policy">
+			<p>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:</p>
+			
+			<ul>
+				<li>The IP address from which you access the web site;</li>
+				<li>The type of browser and operating system you use to access our site;</li>
+				<li>The date and time you access our site;</li>
+				<li>The pages you visit; and</li>
+				<li>The addresses of pages from where you followed a link to our site.</li>
+			</ul>
+
+			<p>Part of this information is gathered using a tracking cookie set by the 
+			<a href="http://www.google.com/analytics" class="externalLink" target="_blank">Google
Analytics</a> service 
+			and handled by Google as described in their 
+			<a href="http://www.google.com/privacy.html" class="externalLink" target="_blank">privacy
policy</a>. 
+			See your browser documentation for instructions on how to disable the cookie if you prefer
not to share 
+			this data with Google.</p>
+
+			<p>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.</p>
+		
+			<p>By using this web site, you consent to the collection of this data in the manner
and for the purpose described 
+			above.</p>
+		</section>
+	</body>
+</document>

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.
 ]]></pre>	
+			</subsection>
+			
+			<subsection name="An advanced example">
+			
+				<p>This example covers named loggers, layouts and best practices in object-oriented
programming.</p>
+			
+				<p>Create a configuration file named <code>log4php.xml</code> with
the following content:</p>
+				
+<pre class="prettyprint linenums"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration xmlns="http://logging.apache.org/log4php/">
+
+    <appender name="myConsoleAppender" class="LoggerAppenderConsole" />
+    
+    <appender name="myFileAppender" class="LoggerAppenderFile">
+        <layout class="LoggerLayoutTTCC" />
+        <param name="file" value="myLog.log" />
+    </appender>
+
+    <logger name="Foo">
+        <appender_ref ref="myFileAppender" />
+    </logger>
+    
+    <root>
+        <level value="DEBUG" />
+        <appender_ref ref="myConsoleAppender" />
+    </root>
+</configuration>
+]]></pre>
+
+				<p>The configuration defines two appenders: one writes to the console, and the
other to a file.</p>
+				
+				<p>The 
+				console appender doesn't have a layout defined, so it will revert to default layout
+				(<code><a href="docs/layouts/simple.html">LoggerLayoutSimple</a></code>).
The 
+				file appender uses a different layout 
+				(<code><a href="docs/layouts/ttcc.html">LoggerLayoutTTCC</a></code>)
+				which will result in different formatting of the logging 
+				events.</p>
+				
+				<p>The console appender is linked to the root logger. The file appender is linked
to the logger named 
+				<code>Foo</code>, however <code>Foo</code> also inherits appenders
from the root logger (in this case
+				the console appender). This means that logging events sent to the <code>Foo</code>
logger will be 
+				logged both to the console and the file.</p>
 				
+				<p>Consider the following code snippet:</p>
+				
+<pre class="prettyprint linenums"><![CDATA[
+// Include and configure log4php
+include('log4php/Logger.php');
+Logger::configure('log4php.xml');
+
+/**
+ * This is a classic usage pattern: one logger object per class.
+ */
+class Foo
+{
+    /** Holds the Logger. */
+    private $log;
+
+    /** Logger is instantiated in the constructor. */
+    public function __construct()
+    {
+        // The __CLASS__ constant holds the class name, in our case "Foo".
+        // Therefore this creates a logger named "Foo" (which we configured in the config
file)
+        $this->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();
+]]></pre>
+
+  					<p>This produces the following output in the console:</p>
+					<pre>INFO - We have liftoff.</pre>
+
+					<p>And the following in the log file:</p>
+					<pre>01/06/11 18:43:39,545 [5428] INFO Foo - We have liftoff.</pre>
 
+					<p>Note the different layout, this is because LoggerLayoutTTCC was used as layout
for the file appender.</p>
 			</subsection>
+			
 		</section>
 	</body>
 </document>



Mime
View raw message