logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ihabu...@apache.org
Subject svn commit: r1294503 [2/3] - in /logging/log4php/trunk/src: changes/ main/php/ main/php/appenders/ main/php/helpers/ main/php/layouts/ main/php/pattern/ site/xdoc/docs/layouts/ test/php/ test/php/appenders/ test/php/helpers/ test/php/layouts/ test/php/...
Date Tue, 28 Feb 2012 07:49:23 GMT
Added: logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterMessage.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterMessage.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterMessage.php (added)
+++ logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterMessage.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,32 @@
+<?php
+/**
+ * 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.
+ *
+ * @package log4php
+ */
+
+/**
+ * Returns the logged message.
+ * 
+ * @package log4php
+ * @subpackage pattern
+ */
+class LoggerPatternConverterMessage extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return $event->getRenderedMessage();
+	}
+}

Added: logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterMethod.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterMethod.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterMethod.php (added)
+++ logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterMethod.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,33 @@
+<?php
+/**
+ * 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.
+ *
+ * @package log4php
+ */
+
+/**
+ * Returns the name of the function or method from which the logging request 
+ * was issued. 
+ * 
+ * @package log4php
+ * @subpackage pattern
+ */
+class LoggerPatternConverterMethod extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return $event->getLocationInformation()->getMethodName();
+	}
+}

Added: logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterNDC.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterNDC.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterNDC.php (added)
+++ logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterNDC.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,33 @@
+<?php
+/**
+ * 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.
+ *
+ * @package log4php
+ */
+
+/**
+ * Returns the full Nested Diagnostic Context.
+ * 
+ * @package log4php
+ * @subpackage pattern
+ */
+class LoggerPatternConverterNDC extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return $event->getNDC();
+	}
+}
+ 
\ No newline at end of file

Added: logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterNewLine.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterNewLine.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterNewLine.php (added)
+++ logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterNewLine.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,32 @@
+<?php
+/**
+ * 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.
+ *
+ * @package log4php
+ */
+
+/**
+ * Returns platform-specific newline character(s). 
+ * 
+ * @package log4php
+ * @subpackage pattern
+ */
+class LoggerPatternConverterNewLine extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return PHP_EOL;
+	}
+}

Added: logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterProcess.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterProcess.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterProcess.php (added)
+++ logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterProcess.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,32 @@
+<?php
+/**
+ * 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.
+ *
+ * @package log4php
+ */
+
+/**
+ * Returns the PID of the current process.
+ * 
+ * @package log4php
+ * @subpackage pattern
+ */
+class LoggerPatternConverterProcess extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return getmypid();
+	}
+}

Added: logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterRelative.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterRelative.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterRelative.php (added)
+++ logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterRelative.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,34 @@
+<?php
+/**
+ * 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.
+ *
+ * @package log4php
+ */
+
+/**
+ * Returns the number of milliseconds elapsed since the start of the 
+ * application until the creation of the logging event.
+ * 
+ * @package log4php
+ * @subpackage pattern
+ */
+class LoggerPatternConverterRelative extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		$ts = $event->getTimeStamp() - $event->getStartTime();
+		return number_format($ts, 4);
+	}
+}

Added: logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterRequest.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterRequest.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterRequest.php (added)
+++ logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterRequest.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,33 @@
+<?php
+/**
+ * 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.
+ *
+ * @package log4php
+ */
+
+/**
+ * Returns a value from the $_REQUEST superglobal array corresponding to the 
+ * given key.
+ * 
+ * Options:
+ *  [0] $_REQUEST key value
+ * 
+ * @package log4php
+ * @subpackage pattern
+ */
+class LoggerPatternConverterRequest extends LoggerPatternConverterSuperglobal {
+	protected $name = '_REQUEST';
+}
\ No newline at end of file

Added: logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterServer.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterServer.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterServer.php (added)
+++ logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterServer.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,33 @@
+<?php
+/**
+ * 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.
+ *
+ * @package log4php
+ */
+
+/**
+ * Returns a value from the $_SERVER superglobal array corresponding to the 
+ * given key.
+ * 
+ * Options:
+ *  [0] $_SERVER key value
+ * 
+ * @package log4php
+ * @subpackage pattern
+ */
+class LoggerPatternConverterServer extends LoggerPatternConverterSuperglobal {
+	protected $name = '_SERVER';
+}

Added: logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterSession.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterSession.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterSession.php (added)
+++ logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterSession.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,33 @@
+<?php
+/**
+ * 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.
+ *
+ * @package log4php
+ */
+
+/**
+ * Returns a value from the $_SESSION superglobal array corresponding to the 
+ * given key.
+ * 
+ * Options:
+ *  [0] $_SESSION key value
+ * 
+ * @package log4php
+ * @subpackage pattern
+ */
+class LoggerPatternConverterSession extends LoggerPatternConverterSuperglobal {
+	protected $name = '_SESSION';
+}

Added: logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterSessionID.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterSessionID.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterSessionID.php (added)
+++ logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterSessionID.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,31 @@
+<?php
+/**
+ * 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.
+ *
+ * @package log4php
+ */
+
+/**
+ * Returns the active session ID, or an empty string if out of session. 
+ * 
+ * @package log4php
+ * @subpackage pattern
+ */
+class LoggerPatternConverterSessionID extends LoggerPatternConverter {
+	public function convert(LoggerLoggingEvent $event) {
+		return session_id();
+	}
+}

Added: logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterSuperglobal.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterSuperglobal.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterSuperglobal.php (added)
+++ logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterSuperglobal.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,99 @@
+<?php
+/**
+ * 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.
+ *
+ * @package log4php
+ */
+
+/**
+ * Returns a value from a superglobal array corresponding to the 
+ * given key.
+ * 
+ * Option: the key to look up within the superglobal array
+ * 
+ * Also, it is possible that a superglobal variable is not populated by PHP
+ * because of the settings in the variables-order ini directive. In this case
+ * the converter will return an empty value.
+ * 
+ * @see http://php.net/manual/en/language.variables.superglobals.php
+ * @see http://www.php.net/manual/en/ini.core.php#ini.variables-order
+ * @package log4php
+ * @subpackage pattern
+ */
+abstract class LoggerPatternConverterSuperglobal extends LoggerPatternConverter {
+
+	/** 
+	 * Name of the superglobal variable, to be defined by subclasses. 
+	 * For example: "_SERVER" or "_ENV". 
+	 */
+	protected $name;
+	
+	protected $value = '';
+	
+	public function activateOptions() {
+		// Read the key from options array
+		if (isset($this->option) && $this->option !== '') {
+			$key = $this->option;
+		}
+	
+		/*
+		 * There is a bug in PHP which doesn't allow superglobals to be 
+		 * accessed when their name is stored in a variable, e.g.:
+		 * 
+		 * $name = '_SERVER';
+		 * $array = $$name;
+		 * 
+		 * This code does not work when run from within a method (only when run
+		 * in global scope). But the following code does work: 
+		 * 
+		 * $name = '_SERVER';
+		 * global $$name;
+		 * $array = $$name;
+		 * 
+		 * That's why global is used here.
+		 */
+		global ${$this->name};
+			
+		// Check the given superglobal exists. It is possible that it is not initialized.
+		if (!isset(${$this->name})) {
+			$class = get_class($this);
+			trigger_error("log4php: $class: Cannot find superglobal variable \${$this->name}.", E_USER_WARNING);
+			return;
+		}
+		
+		$source = ${$this->name};
+		
+		// When the key is set, display the matching value
+		if (isset($key)) {
+			if (isset($source[$key])) {
+				$this->value = $source[$key]; 
+			}
+		}
+		
+		// When the key is not set, display all values
+		else {
+			$values = array();
+			foreach($source as $key => $value) {
+				$values[] = "$key=$value";
+			}
+			$this->value = implode(', ', $values);			
+		}
+	}
+	
+	public function convert(LoggerLoggingEvent $event) {
+		return $this->value;
+	}
+}

Added: logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterThrowable.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterThrowable.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterThrowable.php (added)
+++ logging/log4php/trunk/src/main/php/pattern/LoggerPatternConverterThrowable.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,68 @@
+<?php
+/**
+ * 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.
+ *
+ * @package log4php
+ */
+
+/**
+ * Returns the throwable information linked to the logging event, if any.
+ * 
+ * Option: the maximum stack trace lines to return (returns all if not set)
+ * 
+ * @package log4php
+ * @subpackage pattern
+ */
+class LoggerPatternConverterThrowable extends LoggerPatternConverter {
+	
+	private $depth;
+	
+	public function activateOptions() {
+		if (isset($this->option) && is_numeric($op) && $op >= 0) {
+			$this->depth = (integer) $this->option;
+		}
+	}
+	
+	public function convert(LoggerLoggingEvent $event) {
+		
+		$info = $event->getThrowableInformation();
+		if ($info === null) {
+			return '';
+		}
+		
+		$ex = $info->getThrowable();
+		
+		// Format exception to string
+		$strEx = get_class($ex) . ': "' . $ex->getMessage() . '"' . PHP_EOL;
+		$strEx .= 'at '. $ex->getFile() . ':' . $ex->getLine();
+		
+		// Add trace if required
+		if ($this->depth === null || $this->depth > 0) {
+			$trace = $ex->getTrace();
+			foreach($trace as $key => $item) {
+				if (isset($this->depth) && $key > $this->depth) {
+					break;
+				}
+				$strEx .= PHP_EOL . "#$key " . 
+					"{$item['file']}:{$item['line']} " .
+					"in {$item['class']}{$item['type']}{$item['function']}()"; 
+			}
+		}
+		
+		return $strEx;
+	}
+}
+ 
\ No newline at end of file

Modified: logging/log4php/trunk/src/site/xdoc/docs/layouts/pattern.xml
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/site/xdoc/docs/layouts/pattern.xml?rev=1294503&r1=1294502&r2=1294503&view=diff
==============================================================================
--- logging/log4php/trunk/src/site/xdoc/docs/layouts/pattern.xml (original)
+++ logging/log4php/trunk/src/site/xdoc/docs/layouts/pattern.xml Tue Feb 28 07:49:21 2012
@@ -45,7 +45,7 @@
 							<td>conversionPattern</td>
 							<td>string</td>
 							<td>No</td>
-							<td>%m%n</td>
+							<td>%message%newline</td>
 							<td>String which controls the output. See full specification below.</td>
 						</tr>
 					</tbody>
@@ -53,239 +53,429 @@
 				
 				<h4>Conversion patterns</h4>
 				
-					<p>This is the string which controls formatting and consists of a mix of literal content and 
-					conversion specifiers.</p>
+				<p><strong>Conversion pattern</strong> is a string which controls the formatting of logging 
+				events. It controls how logging events will be transformed into strings by the layout.</p>
+			
+				<p>The conversion pattern is closely related to the conversion pattern of the 
+				<a href="http://www.cplusplus.com/reference/clibrary/cstdio/printf" target="_blank">printf</a> 
+				function in C(++). It is composed of literal text and format control expressions called <em>conversion 
+				specifiers</em>.</p>
 				
-					<p>The conversion pattern is closely related to the conversion pattern of the 
-					<a href="http://www.cplusplus.com/reference/clibrary/cstdio/printf" target="_blank">printf</a> 
-					function in C. It is composed of literal text and format control expressions called conversion 
-					specifiers. You are free to insert any literal text within the conversion pattern.</p>
-					
-					<p>Each conversion specifier starts with a percent sign (%) and is followed by optional <em>
-					format modifiers</em> and a <em>conversion character</em>. The recognized conversion specifiers 
-					are:</p>
+				<p>A conversion specifier begins with a percent sign (%) and is followed by a <em>conversion word</em>.
+				Some conversion words require one or more <em>options</em> to be given. These are specified in braces after the 
+				conversion word. An example of a conversion specifier is <code>%message</code> which will be converted into
+				the message from the logging event which is being logged.</p>
+				
+				<p>The recognized conversion specifiers are:</p>
 					
-					<table>
-						<thead>
-							<tr>
-								<th>Conversion character</th>
-								<th>Converts to</th>
-							</tr>
-						</thead>
-						<tbody>
-							<tr>
-								<td>
-									<p><code>%c</code></p>
-									<p><code>%c{<![CDATA[<precision>]]>}</code></p>
-								</td>
-								<td>
-									<p>Name of the Logger object which recieved the logging request.</p>
-									
-									<p>Optionally, it can be can followed by <em>precision specifier</em>, which is a 
-									decimal constant in brackets. If a precision specifier is given, then only the 
-									corresponding number of right most components of the logger name will be printed.</p>
-									
-									<p>For example, if the logger is named <code>foo.bar.Baz</code>, then <code>%c</code>
-									will be translated to the full logger name, <code>%c{2}</code> will be translated to
-									<code>bar.Baz</code>, and <code>%c{1}</code> will be translated to <code>Baz</code>.
-									</p>
-								</td>
-							</tr>
-							<tr>
-								<td>
-									<p><code>%C</code></p>
-									<p><code>%C{<![CDATA[<precision>]]>}</code></p>
-								</td>
-								<td>
-									<p>The fully qualified class name of the caller issuing the logging request. Currently,
-									this will always return "Logger".</p>
-								</td>
-							</tr>
-							<tr>
-								<td>
-									<p><code>%d</code></p>
-									<p><code>%d{<![CDATA[<format>]]>}</code></p>
-								</td>
-								<td>
-									<p>The date of the logging event.</p>
-									
-									<p>Optionally, may be followed by a <em>date format specifier</em> enclosed between 
-									braces. The format specifier follows the PHP 
-									<a href="http://php.net/manual/en/function.date.php">date</a> function. If no date 
-									format specifier is given then ISO8601 format is assumed (Y-m-d H:i:s,u). </p>
-									 
-									<p>For example: <code>%d{Y-m-d H:i:s}</code></p>
-								</td>
-							</tr>
-							<tr>
-								<td><code>%F</code></td>
-								<td>Name of the file from which the logging request was issued.</td>
-							</tr>
-							<tr>
-								<td><code>%l</code></td>
-								<td>
-									<p>Location information of the caller which generated the logging event.</p>
-									<p>Identical to <code>%C.%M(%F:%L)</code></p>
-								</td>
-							</tr>
-							<tr>
-								<td><code>%L</code></td>
-								<td>The line number at which the logging request was issued.</td>
-							</tr>
-							<tr>
-								<td><code>%m</code></td>
-								<td>The message associated with the logging event.</td>
-							</tr>
-							<tr>
-								<td><code>%n</code></td>
-								<td>
-									<p>A platform dependent line-break character(s).</p>
-									<p>Note that a line break will not be printed unless explicitely specified.</p>
-								</td>
-							</tr>
-							<tr>
-								<td><code>%M</code></td>
-								<td>The method or function name from which the logging request was issued.</td>
-							</tr>
-							<tr>
-								<td><code>%p</code></td>
-								<td>The level of the logging event.</td>
-							</tr>
-							<tr>
-								<td><code>%r</code></td>
-								<td>The number of milliseconds elapsed since the start of the application until the creation of the logging event.</td>
-							</tr>
-							<tr>
-								<td><code>%t</code></td>
-								<td>The ID of the process that generated the logging event.</td>
-							</tr>
-							<tr>
-								<td><code>%x</code></td>
-								<td>The NDC (Nested Diagnostic Context) associated with the thread that generated the logging event.</td>
-							</tr>
-							<tr>
-								<td><code>%X{<![CDATA[<key>]]>}</code></td>
-								<td>
-									<p>The MDC (Mapped Diagnostic Context) associated with the thread that generated the 
-									logging event.</p>
-									<p>The X conversion character must be followed by the MDC key in braces. The value in 
-									the MDC corresponding to the key will be output.</p>
-								</td>
-							</tr>
-							<tr>
-								<td><code>%%</code></td>
-								<td>A single percent sign.</td>	
-							</tr>
-						</tbody>
-					</table>			
-				</subsection>
+				<table class="table table-bordered">
+				    <thead>
+    				    <tr>
+    						<th>Conversion specifier</th>
+    						<th>Converts to</th>
+    				    </tr>
+				    </thead>
+				    <tbody>
+    					<tr>
+    						<td>
+    						    <p><strong>%c</strong>{length}</p>
+    							<p><strong>%lo</strong>{length}</p>
+    							<p><strong>%logger</strong>{length}</p>
+    						</td>
+    						<td>
+    							<p>Name of the Logger which generated the logging request.</p>
+    							
+    							<p>Optionally, a desired output length can be specified. If given, the converter will attempt
+    							to abbreviate the logger name without losing too much information in the process. If 
+    							zero length is specified, only the rightmost name fragment will be output.</p>
+    							
+    							<p>Specifying the desired length 0 means that only the class name will be returned without
+    							the corresponding namespace.</p>
+   							
+    							<p>Several examples of the shortening algorithm in action:</p>
+    							
+    						    <table class="table table-bordered table-not-wide">
+    								<thead>
+    									<tr>
+    										<th>Conversion specifier</th>
+    										<th>Logger name</th>
+    										<th>Result</th>
+    									</tr>
+    								</thead>
+    								<tbody>
+    									<tr>
+    										<td>%logger</td>
+    										<td>org\apache\logging\log4php\Foo</td>
+    										<td>org\apache\logging\log4php\Foo</td>
+    									</tr>
+    									<tr>
+    										<td>%logger{0}</td>
+    										<td>org\apache\logging\log4php\Foo</td>
+    										<td>Foo</td>
+    									</tr>
+    									<tr>
+    										<td>%logger{10}</td>
+    										<td>org\apache\logging\log4php\Foo</td>
+    										<td>o\a\l\l\Foo</td>
+    									</tr>
+    									<tr>
+    										<td>%logger{20}</td>
+    										<td>org\apache\logging\log4php\Foo</td>
+    										<td>o\a\l\log4php\Foo</td>
+    									</tr>
+    									<tr>
+    										<td>%logger{25}</td>
+    										<td>org\apache\logging\log4php\Foo</td>
+    										<td>o\a\logging\log4php\Foo</td>
+    									</tr>
+    									<tr>
+    										<td>%logger{30}</td>
+    										<td>org\apache\logging\log4php\Foo</td>
+    										<td>org\apache\logging\log4php\Foo</td>
+    									</tr>
+    								</tbody>
+    							</table>
+    							
+    							<p>Note that rightmost segment will never be shortened. It is possible that the 
+    							resulting string will be longer than the specified desired length.</p>
+    							<p>For backward compatibility, a dot can be used as a namespace separator, as well as
+    							the backslash.</p>
+    						</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%C</strong>{length}</p>
+    							<p><strong>%class</strong>{length}</p>
+    						</td>
+    						<td>
+    							<p>The fully qualified class name of the caller issuing the logging request.</p>
+    							<p>Just like <strong>%logger</strong>, a desired length can be defined as an option.</p>
+    						</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%cookie</strong>{key}</p>
+    						</td>
+    						<td>
+    							<p>A value from the $_COOKIE superglobal array corresponding to the given key.</p>
+    							<p>If no key is given, will return all values in key=value format.</p>
+    						</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%d</strong>{pattern}</p>
+    							<p><strong>%date</strong>{pattern}</p>
+    						</td>
+    						<td>
+    							<p>The date/time of the logging event. Accepts a pattern string as an option. The 
+    							pattern syntax is the same as used by the PHP's <code><a href="http://php.net/manual/en/function.date.php" 
+    							target="_blank" class="externalLink">date()</a></code> function.</p>
+    							
+    							<p>If no pattern is given, the date format will default to the ISO8601 datetime format,
+    							which is the same as giving the pattern: <code>c</code>.</p>
+    							
+    							<table>
+    								<thead>
+    									<tr>
+    										<th>Conversion specifier</th>
+    										<th>Result</th>
+    									</tr>
+    								</thead>
+    								<tbody>
+    									<tr>
+    										<td>%d</td>
+    										<td>2011-12-27T12:01:32+01:00</td>
+    									</tr>
+    									<tr>
+    										<td>%date</td>
+    										<td>2011-12-27T12:01:32+01:00</td>
+    									</tr>
+    									<tr>
+    										<td>%date{ISO8601}</td>
+    										<td>2011-12-27T12:01:32+01:00</td>
+    									</tr>
+    									<tr>
+    										<td>%date{Y-m-d H:i:s,u}</td>
+    										<td>2011-12-27 12:01:32,610</td>
+    									</tr>
+    									<tr>
+    										<td>%date{l jS \of F Y h:i:s A}</td>
+    										<td>Tuesday 27th of December 2011 12:01:32 PM</td>
+    									</tr>
+    								</tbody>
+    							</table>
+    						</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%e</strong>{key}</p>
+    							<p><strong>%env</strong>{key}</p>
+    						</td>
+    						<td>
+    							<p>A value from the $_ENV superglobal array corresponding to the given key.</p>
+    							<p>If no key is given, will return all values in key=value format.</p>
+    						</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%F</strong></p>
+    							<p><strong>%file</strong></p>
+    						</td>
+    						<td>Name of the file from which the logging request was issued.</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%l</strong></p>
+    							<p><strong>%location</strong></p>
+    						</td>
+    						<td>
+    							<p>Location information of the caller which generated the logging event.</p>
+    							<p>Identical to <code>%C.%M(%F:%L)</code></p>
+    						</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%L</strong></p>
+    							<p><strong>%line</strong></p>
+    						</td>
+    						<td>The line number at which the logging request was issued.</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%m</strong></p>
+    							<p><strong>%msg</strong></p>
+    							<p><strong>%message</strong></p>
+    						</td>
+    						<td>The message associated with the logging event.</td>
+    					</tr>
+    					<tr>
+    						<td>
+    						    <p><strong>%n</strong></p>
+    							<p><strong>%newline</strong></p>
+    						</td>
+    						<td>
+    							<p>A platform dependent line-break character(s).</p>
+    							<p>Note that a line break will not be printed unless explicitely specified.</p>
+    						</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%M</strong></p>
+    							<p><strong>%method</strong></p>
+    						</td>
+    						<td>The method or function name from which the logging request was issued.</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%p</strong></p>
+    							<p><strong>%le</strong></p>
+    							<p><strong>%level</strong></p>
+    						</td>
+    						<td>The level of the logging event.</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%r</strong></p>
+    							<p><strong>%relative</strong></p>
+    						</td>
+    						<td>The number of milliseconds elapsed since the start of the application until the creation of the logging event.</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%req</strong>{key}</p>
+    							<p><strong>%request</strong>{key}</p>
+    						</td>
+    						<td>
+    							<p>A value from the $_REQUEST superglobal array corresponding to the given key.</p>
+    							<p>If no key is given, will return all values in key=value format.</p>
+    						</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%s</strong>{key}</p>
+    							<p><strong>%server</strong>{key}</p>
+    						</td>
+    						<td>
+    							<p>A value from the $_SERVER superglobal array corresponding to the given key.</p>
+    							<p>If no key is given, will return all values in key=value format.</p>
+    						</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%t</strong></p>
+    							<p><strong>%pid</strong></p>
+    							<p><strong>%process</strong></p>
+    						</td>
+    						<td>The ID of the process that generated the logging event.</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%x</strong></p>
+    							<p><strong>%ndc</strong></p>
+    						</td>
+    						<td>The NDC (Nested Diagnostic Context) associated with the thread that generated the logging event.</td>
+    					</tr>
+    					<tr>
+    						<td>
+    							<p><strong>%X</strong>{key}</p>
+    							<p><strong>%mdc</strong>{key}</p>
+    						</td>
+    						<td>
+    							<p>A value from the Mapped Diagnostic Context (MDC) corresponding to the given key.</p>
+    						</td>
+    					</tr>
+                    </tbody>
+				</table>			
+			</subsection>
 		
-				<subsection name="Format modifiers">
-					<p>By default the relevant information is output as-is. However, with the aid of format modifiers 
-					it is possible to change the minimum and maximum width and the justifications of each data field.
-					</p>
-					
-					<p>All format modifiers are optional, and are placed between the percent sign and the conversion 
-					character.</p>
-					
-					<p>The first format modifier is the <em>left justification flag</em> which is just the minus (-)
-					character.</p>
-					 
-					<p>Then comes the <em>>minimum field width</em> modifier. This is an integer that 
-					represents the minimum number of characters to output. If the data item requires fewer characters,
-					it is padded on either the left or the right until the minimum width is reached. The default is to
-					pad on the left (right justify) but you can specify right padding with the left justification flag.
-					The padding character is space. If the data item is larger than the minimum field width, the field
-					is expanded to accommodate the data. The value is never truncated. </p>
-					 
-					<p>This behavior can be changed using the <em>maximum field width</em> modifier which is designated
-					by a period (.) followed by an integer. If the data item is longer than the maximum field, then the
-					extra characters are removed from the beginning of the data item and not from the end. For example,
-					it the maximum field width is eight and the data item is ten characters long, then the first two 
-					characters of the data item are dropped. This behavior deviates from the printf function in C where
-					truncation is done from the end. </p>
-					
-					<p>The following table demonstrates various uses of format modifiers:</p>
-					
-					<table>
-						<thead>
-							<tr>
-								<th>Format modifier</th>
-								<th>Justification</th>
-								<th>Minimum width</th>
-								<th>Maximum width</th>
-								<th>Comment</th>
-							</tr>
-						</thead>
-						<tbody>
-							<tr>
-								<td align="center"><code>%c</code></td>
-								<td align="center">none</td>
-								<td align="center">none</td>
-								<td align="center">none</td>
-								<td>Output the logger name as-is.</td>
-							</tr>
-							<tr>
-								<td align="center"><code>%20c</code></td>
-								<td align="center">right</td>
-								<td align="center">20</td>
-								<td align="center">none</td>
-								<td>Left pad with spaces if the logger name is less than 20 characters long.</td>
-							</tr>
-							<tr>
-								<td align="center"><code>%-20c</code></td>
-								<td align="center">left</td>
-								<td align="center">20</td>
-								<td align="center">none</td>
-								<td>Right pad with spaces if the logger name is less than 20 characters long.</td>
-							</tr>
-							<tr>
-								<td align="center"><code>%.30c</code></td>
-								<td align="center">none</td>
-								<td align="center">none</td>
-								<td align="center">30</td>
-								<td>Truncate from the beginning if the logger name is longer than 30 characters.</td>
-							</tr>
-							<tr>
-								<td align="center"><code>%20.30c</code></td>
-								<td align="center">right</td>
-								<td align="center">20</td>
-								<td align="center">30</td>
-								<td>Left pad with spaces if the logger name is shorter than 20 characters. However, if 
-								the logger name is longer than 30 characters, then truncate from the beginning.</td>
-							</tr>
-							<tr>
-								<td align="center"><code>%-20.30c</code></td>
-								<td align="center">true</td>
-								<td align="center">20</td>
-								<td align="center">30</td>
-								<td>Right pad with spaces if the logger name is shorter than 20 characters. However, if the
-								logger name is longer than 30 characters, then truncate from the beginning.</td>
-							</tr>
-						</tbody>
-					</table> 
-				</subsection>
+			<subsection name="Format modifiers">
+				<p>By default the relevant information is output as-is. However, with the aid of format modifiers 
+				it is possible to change the minimum and maximum width and the justifications of each data field.
+				</p>
+				
+				<p>All format modifiers are optional, and are placed between the percent sign and the conversion 
+				word.</p>
+				
+				<p>The first format modifier is the <em>left justification flag</em> which is just the minus (-)
+				character.</p>
+				 
+				<p>Then comes the <em>>minimum field width</em> modifier. This is an integer that 
+				represents the minimum number of characters to output. If the data item requires fewer characters,
+				it is padded on either the left or the right until the minimum width is reached. The default is to
+				pad on the left (right justify) but you can specify right padding with the left justification flag.
+				The padding character is space. If the data item is larger than the minimum field width, the field
+				is expanded to accommodate the data. The value is never truncated. </p>
+				 
+				<p>This behavior can be changed using the <em>maximum field width</em> modifier which is designated
+				by a period (.) followed by an integer. If the data item is longer than the maximum field, then the
+				extra characters are removed from the beginning of the data item and not from the end. For example,
+				it the maximum field width is eight and the data item is ten characters long, then the first two 
+				characters of the data item are dropped. This behavior deviates from the printf function in C where
+				truncation is done from the end. </p>
+				
+				<p>The following table demonstrates various uses of format modifiers:</p>
+				
+				<table>
+					<thead>
+						<tr>
+							<th>Format modifier</th>
+							<th>Padding</th>
+							<th>Trimming</th>
+							<th>Minimum width</th>
+							<th>Maximum width</th>
+							<th>Comment</th>
+						</tr>
+					</thead>
+					<tbody>
+						<tr>
+							<td align="center"><strong>%logger</strong></td>
+							<td align="center">none</td>
+							<td align="center">none</td>
+							<td align="center">none</td>
+							<td align="center">none</td>
+							<td>Output the logger name as-is.</td>
+						</tr>
+						<tr>
+							<td align="center"><strong>%20logger</strong></td>
+							<td align="center">right</td>
+							<td align="center">20</td>
+							<td align="center">none</td>
+							<td>Left pad with spaces if the logger name is less than 20 characters long.</td>
+						</tr>
+						<tr>
+							<td align="center"><strong>%-20logger</strong></td>
+							<td align="center">left</td>
+							<td align="center">20</td>
+							<td align="center">none</td>
+							<td>Right pad with spaces if the logger name is less than 20 characters long.</td>
+						</tr>
+						<tr>
+							<td align="center"><strong>%.30logger</strong></td>
+							<td align="center">none</td>
+							<td align="center">none</td>
+							<td align="center">30</td>
+							<td>Trim from the beginning if the logger name is longer than 30 characters.</td>
+						</tr>
+						<tr>
+							<td align="center"><strong>%.-30logger</strong></td>
+							<td align="center">none</td>
+							<td align="center">none</td>
+							<td align="center">30</td>
+							<td>Trim from the end if the logger name is longer than 30 characters.</td>
+						</tr>
+						<tr>
+							<td align="center"><strong>%20.30logger</strong></td>
+							<td align="center">right</td>
+							<td align="center">20</td>
+							<td align="center">30</td>
+							<td>Left pad with spaces if the logger name is shorter than 20 characters. However, if 
+							the logger name is longer than 30 characters, then trim from the beginning.</td>
+						</tr>
+						<tr>
+							<td align="center"><strong>%-20.30logger</strong></td>
+							<td align="center">true</td>
+							<td align="center">20</td>
+							<td align="center">30</td>
+							<td>Right pad with spaces if the logger name is shorter than 20 characters. However, if the
+							logger name is longer than 30 characters, then trim from the beginning.</td>
+						</tr>
+					</tbody>
+				</table>
+				
+				<p>The following table lists a couple of examples for using format modifiers. Note that the square
+				brackets are added to the conversion pattern to delimit the output.</p>
+				
+				<table class="table table-bordered table-striped table-not-wide">
+					<thead>
+						<tr>
+							<th>Conversion pattern</th>
+							<th>Logger name</th>
+							<th>Result</th>
+						</tr>
+					</thead>
+					<tbody>
+						<tr>
+							<td>[%10.10logger]</td>
+							<td>Foo</td>
+							<td><code>[&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Foo]</code></td>
+						</tr>
+						<tr>
+							<td>[%-10.10logger]</td>
+							<td>Foo</td>
+							<td><code>[Foo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]</code></td>
+						</tr>
+						<tr>
+							<td>[%10.10logger]</td>
+							<td>org.apache.log4php.Foo</td>
+							<td><code>[og4php.Foo]</code></td>
+						</tr>
+						<tr>
+							<td>[%10.-10logger]</td>
+							<td>org.apache.log4php.Foo</td>
+							<td><code>[org.apache]</code></td>
+						</tr>
+					</tbody>
+				</table>
+			</subsection>
 
-				<subsection name="Examples">
-					<p>The following configuration configures a <code>LoggerAppenderEcho</code> which uses the pattern
-					layout. All examples will use the same code and configuration, only the conversion pattern will 
-					change.</p>
-					
-					<p>Save the configuration to a file called <code>layout_pattern.xml</code>.</p>
+			<subsection name="Examples">
+				<p>The following configuration configures a <code>LoggerAppenderEcho</code> which uses the pattern
+				layout. All examples will use the same code and configuration, only the conversion pattern will 
+				change from example to example.</p>
+				
+				<div class="auto-tabs">
+					<ul>
+						<li>XML</li>
+						<li>PHP</li>
+					</ul>
 	
-					<div class="auto-tabs">
-						<ul>
-							<li>XML</li>
-							<li>PHP</li>
-						</ul>
-		
-							<div class="tab-content" >
-								<div class="tab-pane">
+						<div class="tab-content" >
+							<div class="tab-pane">
 <pre class="prettyprint linenums"><![CDATA[
 <configuration xmlns="http://logging.apache.org/log4php/">
     <appender name="default" class="LoggerAppenderEcho">
         <layout class="LoggerLayoutPattern">
-            <param name="conversionPattern" value="%d{Y-m-d H:i:s.u} %c %-5p %m%n" />
+            <param name="conversionPattern" value="%date %logger %-5level %msg%n" />
         </layout>
     </appender>
     <root>
@@ -293,8 +483,8 @@
     </root>
 </configuration>
 ]]></pre>
-								</div>
-								<div class="tab-pane">
+							</div>
+							<div class="tab-pane">
 <pre class="prettyprint linenums"><![CDATA[
 array(
     'appenders' => array(
@@ -303,7 +493,7 @@ array(
             'layout' => array(
                 'class' => 'LoggerLayoutPattern',
                 'params' => array(
-                    'conversionPattern' => '%d{Y-m-d H:i:s.u} %c %-5p %m%n'
+                    'conversionPattern' => '%date %logger %-5level %msg%n'
                 )
             )
         )
@@ -313,36 +503,72 @@ array(
     ),
 )
 ]]></pre>
-							</div>
 						</div>
 					</div>
-					
+				</div>
+				
 
-					<p>Run the following code:</p>
+				<p>Example code:</p>
 
 <pre class="prettyprint linenums">
-Logger::configure("layout_pattern.xml");
+Logger::configure("config.xml");
 $logger = Logger::getLogger('myLogger');
 $logger->info("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
 $logger->debug("Donec a diam lectus.");
 $logger->warn("Sed sit amet ipsum mauris.");
 </pre>
 
-					<h4>Pattern example</h4>
-					<p>Conversion pattern: <code>%d %c %-5p %m%n</code></p>
+				<h4>A simple example</h4>
 				
-					<p>Produces the following output:</p>
+			    <p>Conversion pattern: <code>%date %logger %-5level %msg%n</code></p>
+			
+				<p>Running the example code produces the following output:</p>
 
 <pre>
-2011-09-28 09:29:38,602 myLogger INFO  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-2011-09-28 09:29:38,603 myLogger DEBUG Donec a diam lectus.
-2011-09-28 09:29:38,604 myLogger WARN  Sed sit amet ipsum mauris.
+2012-02-27T19:42:17+01:00 myLogger INFO  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+2012-02-27T19:42:17+01:00 myLogger DEBUG Donec a diam lectus.
+2012-02-27T19:42:17+01:00 myLogger WARN  Sed sit amet ipsum mauris.
 </pre>
 
-					<p>In this example, <code>%d</code> produces the event datetime in default format 
-					(<code>Y-m-d H:i:s,u</code>), and <code>%-5p</code> produces the event level right padded to 5 
-					characters. Since longest level name is 5 characters long, this ensures that the message always 
-					starts at the same character position which improves log readability.</p>
+			    <p>In this example, <code>%date</code> is converted to the event datetime in default format 
+			    (corresponding to the ISO-8601 specification), and <code>%-5level</code> produces the event 
+			    level right padded to 5 characters. Since longest level name is 5 characters long, this 
+			    ensures that the message always starts at the same character position which improves log 
+			    readability.</p>
+			    
+			    <p>Notice that the newline between logging events (%n) has to be explicitely defined. Otherwise all 
+			    logging events will be logged in the same line.</p>
+			    
+			    <h4>Formatting the date</h4>
+			    
+			    <p>The <code>%date</code> conversion word can take the desired date format as an option. For example, 
+			    if you're European, the d.m.Y date format might be more familiar. Also, adding milliseconds.</p>
+			    
+			    <p>Conversion pattern: <code>%date{d.m.Y H:i:s,u} %logger %-5level %msg%n</code></p>
+			    
+				<p>Running the example code produces the following output:</p>
+
+<pre>
+27.02.2012 20:14:41,624 myLogger INFO  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+27.02.2012 20:14:41,625 myLogger DEBUG Donec a diam lectus.
+27.02.2012 20:14:41,626 myLogger WARN  Sed sit amet ipsum mauris.
+</pre>
+			    
+			    <h4>Logging HTTP requests</h4>
+			    
+			    <p>If log4php is used to log HTTP requests, a pattern like this might be useful:</p>
+			    
+			    <p><code>%date [%pid] From:%server{REMOTE_ADDR}:%server{REMOTE_PORT} Request:[%request] Message: %msg%n</code></p>
+			    
+			    <p>Request <code>/test.php?foo=bar</code> it will produce the output similar to:</p>
+				    
+<pre>
+2012-01-02T14:19:33+01:00 [22924] From:194.152.205.71:11257 Request:[foo=bar] Message: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+2012-01-02T14:19:33+01:00 [22924] From:194.152.205.71:11257 Request:[foo=bar] Message: Donec a diam lectus.
+2012-01-02T14:19:33+01:00 [22924] From:194.152.205.71:11257 Request:[foo=bar] Message: Sed sit amet ipsum mauris.
+</pre>
+				    
+				<p><code>%server{REMOTE_ADDR}</code> is equivalent to PHP code <code>$_SERVER['REMOTE_ADDR']</code>.</p>
 			</subsection>
 		</section>
 	</body>

Modified: logging/log4php/trunk/src/test/php/LoggerMDCTest.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/test/php/LoggerMDCTest.php?rev=1294503&r1=1294502&r2=1294503&view=diff
==============================================================================
--- logging/log4php/trunk/src/test/php/LoggerMDCTest.php (original)
+++ logging/log4php/trunk/src/test/php/LoggerMDCTest.php Tue Feb 28 07:49:21 2012
@@ -40,8 +40,8 @@ class LoggerMDCTest extends PHPUnit_Fram
 	/** A pattern with a non-existant key. */
 	private $pattern4 = "%-5p %c: %X{key_does_not_exist} %m";
 	
-	/** A pattern with an empty key. */
-	private $pattern5 = "%-5p %c: %X{} %m";
+	/** A pattern without a key. */
+	private $pattern5 = "%-5p %c: %X %m";
 	
 	/** A pattern for testing values from $_ENV. */
 	private $patternEnv = "%-5p %c: %X{env.TEST} %m";
@@ -76,31 +76,31 @@ class LoggerMDCTest extends PHPUnit_Fram
 		
 		self::assertSame($expected, $actual);
 		
-		$event = new LoggerLoggingEvent("LoggerLayoutPattern", new Logger("TEST"), LoggerLevel::getLevelInfo(), "Test message");
+		$event = LoggerTestHelper::getInfoEvent("Test message");
 
 		// Pattern with 1 key
 		$actual = $this->formatEvent($event, $this->pattern1);
-		$expected = "INFO  TEST: valueofkey1 Test message";
+		$expected = "INFO  test: valueofkey1 Test message";
 		self::assertEquals($expected, $actual);
 		
 		// Pattern with 2 keys
 		$actual = $this->formatEvent($event, $this->pattern2);
-		$expected = "INFO  TEST: valueofkey1 valueofkey2 Test message";
+		$expected = "INFO  test: valueofkey1 valueofkey2 Test message";
 		self::assertEquals($expected, $actual);
 		
 		// Pattern with 3 keys (one numeric)
 		$actual = $this->formatEvent($event, $this->pattern3);
-		$expected = "INFO  TEST: valueofkey1 valueofkey2 valueofkey3 Test message";
+		$expected = "INFO  test: valueofkey1 valueofkey2 valueofkey3 Test message";
 		self::assertEquals($expected, $actual);
 		
 		// Pattern with non-existant key
 		$actual = $this->formatEvent($event, $this->pattern4);
-		$expected = "INFO  TEST:  Test message";
+		$expected = "INFO  test:  Test message";
 		self::assertEquals($expected, $actual);
 		
 		// Pattern with an empty key
     	$actual = $this->formatEvent($event, $this->pattern5);
-		$expected = "INFO  TEST:  Test message";
+		$expected = "INFO  test: key1=valueofkey1, key2=valueofkey2, 3=valueofkey3 Test message";
 		self::assertEquals($expected, $actual);
 		
 		// Test key removal
@@ -110,7 +110,7 @@ class LoggerMDCTest extends PHPUnit_Fram
 		
 		// Pattern with 1 key, now removed
 		$actual = $this->formatEvent($event, $this->pattern1);
-		$expected = "INFO  TEST:  Test message";
+		$expected = "INFO  test:  Test message";
 		self::assertEquals($expected, $actual);
     }
     
@@ -125,9 +125,9 @@ class LoggerMDCTest extends PHPUnit_Fram
     	self::assertEquals('abc', LoggerMDC::get('env.TEST'));
     	
     	// Test env variable in a pattern
-    	$event = new LoggerLoggingEvent("LoggerLayoutPattern", new Logger("TEST"), LoggerLevel::getLevelInfo(), "Test message");
+    	$event = LoggerTestHelper::getInfoEvent("Test message");
     	$actual = $this->formatEvent($event, $this->patternEnv);
-		$expected = "INFO  TEST: abc Test message";
+		$expected = "INFO  test: abc Test message";
 		self::assertEquals($expected, $actual);
 		
 		// Test reading a non-existant env variable
@@ -144,9 +144,9 @@ class LoggerMDCTest extends PHPUnit_Fram
     	self::assertEquals($value, LoggerMDC::get('server.PHP_SELF'));
     	
 		// Test the server variable in a pattern
-    	$event = new LoggerLoggingEvent("LoggerLayoutPattern", new Logger("TEST"), LoggerLevel::getLevelInfo(), "Test message");
+    	$event = LoggerTestHelper::getInfoEvent("Test message");
     	$actual = $this->formatEvent($event, $this->patternServer);
-		$expected = "INFO  TEST: $value Test message";
+		$expected = "INFO  test: $value Test message";
 		self::assertEquals($expected, $actual);
 		
 		// Test reading a non-existant server variable
@@ -159,6 +159,7 @@ class LoggerMDCTest extends PHPUnit_Fram
 	private function formatEvent($event, $pattern) {
 		$layout = new LoggerLayoutPattern();
 		$layout->setConversionPattern($pattern);
+		$layout->activateOptions();
 		return $layout->format($event);
 	}
 }

Modified: logging/log4php/trunk/src/test/php/LoggerTestHelper.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/test/php/LoggerTestHelper.php?rev=1294503&r1=1294502&r2=1294503&view=diff
==============================================================================
--- logging/log4php/trunk/src/test/php/LoggerTestHelper.php (original)
+++ logging/log4php/trunk/src/test/php/LoggerTestHelper.php Tue Feb 28 07:49:21 2012
@@ -28,33 +28,33 @@
 class LoggerTestHelper {
 	
 	/** Returns a test logging event with level set to TRACE. */
-	public static function getTraceEvent($message = 'test') {
-		return new LoggerLoggingEvent(__CLASS__, new Logger("test"), LoggerLevel::getLevelTrace(), $message);
+	public static function getTraceEvent($message = 'test', $logger = "test") {
+		return new LoggerLoggingEvent(__CLASS__, new Logger($logger), LoggerLevel::getLevelTrace(), $message);
 	}
 	
 	/** Returns a test logging event with level set to DEBUG. */
-	public static function getDebugEvent($message = 'test') {
-		return new LoggerLoggingEvent(__CLASS__, new Logger("test"), LoggerLevel::getLevelDebug(), $message);
+	public static function getDebugEvent($message = 'test', $logger = "test") {
+		return new LoggerLoggingEvent(__CLASS__, new Logger($logger), LoggerLevel::getLevelDebug(), $message);
 	}
 	
 	/** Returns a test logging event with level set to INFO. */
-	public static function getInfoEvent($message = 'test') {
-		return new LoggerLoggingEvent(__CLASS__, new Logger("test"), LoggerLevel::getLevelInfo(), $message);
+	public static function getInfoEvent($message = 'test', $logger = "test") {
+		return new LoggerLoggingEvent(__CLASS__, new Logger($logger), LoggerLevel::getLevelInfo(), $message);
 	}
 	
 	/** Returns a test logging event with level set to WARN. */
-	public static function getWarnEvent($message = 'test') {
-		return new LoggerLoggingEvent(__CLASS__, new Logger("test"), LoggerLevel::getLevelWarn(), $message);
+	public static function getWarnEvent($message = 'test', $logger = "test") {
+		return new LoggerLoggingEvent(__CLASS__, new Logger($logger), LoggerLevel::getLevelWarn(), $message);
 	}
 	
 	/** Returns a test logging event with level set to ERROR. */
-	public static function getErrorEvent($message = 'test') {
-		return new LoggerLoggingEvent(__CLASS__, new Logger("test"), LoggerLevel::getLevelError(), $message);
+	public static function getErrorEvent($message = 'test', $logger = "test") {
+		return new LoggerLoggingEvent(__CLASS__, new Logger($logger), LoggerLevel::getLevelError(), $message);
 	}
 	
 	/** Returns a test logging event with level set to FATAL. */
-	public static function getFatalEvent($message = 'test') {
-		return new LoggerLoggingEvent(__CLASS__, new Logger("test"), LoggerLevel::getLevelFatal(), $message);
+	public static function getFatalEvent($message = 'test', $logger = "test") {
+		return new LoggerLoggingEvent(__CLASS__, new Logger($logger), LoggerLevel::getLevelFatal(), $message);
 	}
 	
 	/** 
@@ -111,6 +111,28 @@ class LoggerTestHelper {
 			),
 		);
 	}
+	
+	/** Returns a simple configuration with one echo appender using the pattern layout. */
+	public static function getEchoPatternConfig($pattern) {
+		return array(
+			'threshold' => 'ALL',
+			'rootLogger' => array(
+				'level' => 'trace',
+				'appenders' => array('default'),
+			),
+			'appenders' => array(
+				'default' => array(
+					'class' => 'LoggerAppenderEcho',
+					'layout' => array(
+						'class' => 'LoggerLayoutPattern',
+						'params' => array(
+							'conversionPattern' => $pattern
+						)
+					),
+				),
+			),
+		);
+	}
 }
 
 ?>
\ No newline at end of file

Modified: logging/log4php/trunk/src/test/php/appenders/LoggerAppenderPDOTest.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/test/php/appenders/LoggerAppenderPDOTest.php?rev=1294503&r1=1294502&r2=1294503&view=diff
==============================================================================
--- logging/log4php/trunk/src/test/php/appenders/LoggerAppenderPDOTest.php (original)
+++ logging/log4php/trunk/src/test/php/appenders/LoggerAppenderPDOTest.php Tue Feb 28 07:49:21 2012
@@ -27,138 +27,135 @@
  * @group appenders
  */
 class LoggerAppenderPDOTest extends PHPUnit_Framework_TestCase {
-    const dsn = 'sqlite:../../../target/pdotest.sqlite';
-    const file = '../../../target/pdotest.sqlite';
-        
-    /** To start with an empty database for each single test. */
-    public function setUp() {
-        if(!extension_loaded('pdo_sqlite')) {
-            self::markTestSkipped("Please install 'pdo_sqlite' in order to run this test");
-        }
-
-        if (file_exists(self::file)) @unlink(self::file);
-    }
-
-    /** Clean up after the last test was run. */
-    public static function tearDownAfterClass() {
-        if (file_exists(self::file)) @unlink(self::file);
-    }
-    
+	const dsn = 'sqlite:../../../target/pdotest.sqlite';
+	const file = '../../../target/pdotest.sqlite';
+	
+	public static function setUpBeforeClass() {
+		if(extension_loaded('pdo_sqlite')) {
+			$drop = 'DROP TABLE IF EXISTS log4php_log;';
+			$create = 'CREATE TABLE log4php_log (
+				timestamp VARCHAR(256),
+				logger VARCHAR(256),
+				level VARCHAR(32),
+				message VARCHAR(4000),
+				thread INTEGER,
+				file VARCHAR(255),
+				line VARCHAR(10)
+			);';
+			
+			$pdo = new PDO(self::dsn);
+			$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+			$pdo->exec($drop);
+			$pdo->exec($create);
+		}
+	}
+	
+	
+	/** To start with an empty database for each single test. */
+	public function setUp() {
+		if(!extension_loaded('pdo_sqlite')) {
+			self::markTestSkipped("Please install 'pdo_sqlite' in order to run this test");
+		}
+	}
+
+	/** Clean up after the last test was run. */
+	public static function tearDownAfterClass() {
+		if (file_exists(self::file)) @unlink(self::file);
+	}
+	
 	public function testRequiresLayout() {
 		$appender = new LoggerAppenderPDO();
 		self::assertFalse($appender->requiresLayout());
 	}
 
-    /** Tests new-style logging using prepared statements and the default SQL definition. */
-    public function testSimpleWithDefaults() {
-        // Log event
-        $event = new LoggerLoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-        $appender = new LoggerAppenderPDO("myname");
-        $appender->setDSN(self::dsn);
-        $appender->activateOptions();
-        $appender->append($event);
-        $appender->close();
-
-        // Test the default pattern %d,%c,%p,%m,%t,%F,%L
-        $db = new PDO(self::dsn);
-        $query = "SELECT * FROM log4php_log";
-        $sth = $db->query($query);
-        $row = $sth->fetch(PDO::FETCH_NUM);
-        self::assertTrue(is_array($row), "No rows found.");
-        self::assertEquals(7, count($row));
-        self::assertEquals(1, preg_match('/^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d,\d\d\d$/', $row[0])); // %d = date
-        self::assertEquals('TEST', $row[1]); // %c = category
-        self::assertEquals('ERROR', $row[2]); // %p = priority
-        self::assertEquals('testmessage', $row[3]); // %m = message
-        if (function_exists('posix_getpid')) {
-            self::assertEquals(posix_getpid(), $row[4]); // %t = thread
-        }
-        self::assertEquals('NA', $row[5]); // %F = file, NA due to phpunit magic
-        self::assertEquals('NA', $row[6]); // %L = line, NA due to phpunit magic
-    }
-
-
-    /** Tests new style prepared statment logging with customized SQL. */
-    public function testCustomizedSql() {
-        // Prepare appender
-        $appender = new LoggerAppenderPDO("myname");
-        $appender->setDSN(self::dsn);
-        $appender->setTable('unittest2');
-        $appender->setInsertSql("INSERT INTO unittest2 (file, line, thread, timestamp, logger, level, message) VALUES (?,?,?,?,?,?,?)");
-        $appender->setInsertPattern("%F,%L,%t,%d,%c,%p,%m");
-        $appender->activateOptions();
-
-        // Action!
-        $event = new LoggerLoggingEvent("LoggerAppenderPDOTest2", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-        $appender->append($event);
-        
-        // Check
-        $db = new PDO(self::dsn);
-        $result = $db->query("SELECT * FROM unittest2");
-        $row = $result->fetch(PDO::FETCH_OBJ);
-        self::assertTrue(is_object($row));
-        self::assertEquals("NA", $row->file); // "NA" due to phpunit magic
-        self::assertEquals("NA", $row->line); // "NA" due to phpunit magic
-        if (function_exists('posix_getpid')) {
-            self::assertEquals(posix_getpid(), $row->thread);
-        }
-        self::assertEquals(1, preg_match('/^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d.\d\d\d$/', $row->timestamp));
-        self::assertEquals('TEST', $row->logger);
-        self::assertEquals('ERROR', $row->level);
-        self::assertEquals('testmessage', $row->message);
-    }
-        
-    /** Tests old-style logging using the $sql variable. */
-    public function testOldStyle() {
-        // Create table with different column order
-        $db = new PDO(self::dsn);
-        $db->exec('CREATE TABLE unittest3 (ts timestamp, level varchar(32), msg varchar(64))');
-
-        // Prepare appender
-        $appender = new LoggerAppenderPDO("myname");
-        $appender->setDSN(self::dsn);
-        $appender->setCreateTable(false);
-        $appender->setSql("INSERT INTO unittest3 (ts, level, msg) VALUES ('%d', '%p', '%m')");
-        $appender->activateOptions();
-
-        // Action!
-        $event = new LoggerLoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-        $appender->append($event);
-
-        // Check
-        $db = new PDO(self::dsn);
-        $result = $db->query("SELECT * FROM unittest3");
-        self::assertFalse($result === false);
-        $row = $result->fetch(PDO::FETCH_OBJ);
-        self::assertTrue(is_object($row));
-        self::assertEquals(1, preg_match('/^\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d.\d\d\d$/', $row->ts));
-        self::assertEquals('ERROR', $row->level);
-        self::assertEquals('testmessage', $row->msg);
-    }
-    
-    /** Tests if log4php throws an Exception if the appender does not work. 
-     * @expectedException LoggerException
-     */
-    public function testException() {
-        $dsn = 'doenotexist';
-        $appender = new LoggerAppenderPDO("myname");
-        $appender->setDSN($dsn);
-        $appender->setCreateTable(true);
-            $appender->activateOptions();
-    }
-    
+	/** Tests new-style logging using prepared statements and the default SQL definition. */
+	public function testSimpleWithDefaults() {
+		// Log event
+		$event = new LoggerLoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
+		$appender = new LoggerAppenderPDO("myname");
+		$appender->setDSN(self::dsn);
+		$appender->activateOptions();
+		$appender->append($event);
+		$appender->close();
+
+		// Test the default pattern
+		$db = new PDO(self::dsn);
+		$query = "SELECT * FROM log4php_log";
+		$sth = $db->query($query);
+		$row = $sth->fetch(PDO::FETCH_NUM);
+		
+		self::assertTrue(is_array($row), "No rows found.");
+		self::assertEquals(7, count($row));
+		self::assertEquals(1, preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $row[0])); // %d = date
+		self::assertEquals('TEST', $row[1]); // %c = category
+		self::assertEquals('ERROR', $row[2]); // %p = priority
+		self::assertEquals('testmessage', $row[3]); // %m = message
+		if (function_exists('posix_getpid')) {
+			self::assertEquals(posix_getpid(), $row[4]); // %t = thread
+		}
+		self::assertEquals('NA', $row[5]); // %F = file, NA due to phpunit magic
+		self::assertEquals('NA', $row[6]); // %L = line, NA due to phpunit magic
+	}
+
+
+	/** Tests new style prepared statment logging with customized SQL. */
+	public function testCustomizedSql() {
+		
+		$dateFormat = "Y-m-d H:i:s";
+		
+		// Prepare appender
+		$appender = new LoggerAppenderPDO("myname");
+		$appender->setDSN(self::dsn);
+		$appender->setInsertSql("INSERT INTO log4php_log (file, line, thread, timestamp, logger, level, message) VALUES (?,?,?,?,?,?,?)");
+		$appender->setInsertPattern("%F,%L,%t,%d\{$dateFormat\},%c,%p,%m");
+		$appender->activateOptions();
+
+		// Action!
+		$event = new LoggerLoggingEvent("LoggerAppenderPDOTest2", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
+		$appender->append($event);
+		
+		$date = date($dateFormat, $event->getTimeStamp());
+		
+		// Check
+		$db = new PDO(self::dsn);
+		$result = $db->query("SELECT * FROM log4php_log");
+		$row = $result->fetch(PDO::FETCH_OBJ);
+		self::assertTrue(is_object($row));
+		self::assertEquals("NA", $row->file); // "NA" due to phpunit magic
+		self::assertEquals("NA", $row->line); // "NA" due to phpunit magic
+		if (function_exists('posix_getpid')) {
+			self::assertEquals(posix_getpid(), $row->thread);
+		}
+		self::assertEquals($date, $row->timestamp);
+		self::assertEquals('TEST', $row->logger);
+		self::assertEquals('ERROR', $row->level);
+		self::assertEquals('testmessage', $row->message);
+	}
+	
+	/** 
+	 * Tests a warning is shown when connecting to invalid dns. 
+ 	 * @expectedException PHPUnit_Framework_Error
+ 	 * @expectedExceptionMessage Failed connecting to database: invalid data source name
+	 */
+	public function testException() {
+		$dsn = 'doenotexist';
+		$appender = new LoggerAppenderPDO("myname");
+		$appender->setDSN($dsn);
+		$appender->activateOptions();
+	}
+	
 	/**
 	 * Check whether close() actually closes the database connection. 
 	 */
-    public function testClose() {
-    	$event = new LoggerLoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-    	
-        $appender = new LoggerAppenderPDO("myname");
-        $appender->setDSN(self::dsn);
-        $appender->activateOptions();
-        $appender->append($event);
-        $appender->close();
-        
-        self::assertNull($appender->getDatabaseHandle());
-    }
+	public function testClose() {
+		$event = new LoggerLoggingEvent("LoggerAppenderPDOTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
+		
+		$appender = new LoggerAppenderPDO("myname");
+		$appender->setDSN(self::dsn);
+		$appender->activateOptions();
+		$appender->append($event);
+		$appender->close();
+		
+		self::assertNull($appender->getDatabaseHandle());
+	}
 }

Modified: logging/log4php/trunk/src/test/php/bootstrap.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/test/php/bootstrap.php?rev=1294503&r1=1294502&r2=1294503&view=diff
==============================================================================
--- logging/log4php/trunk/src/test/php/bootstrap.php (original)
+++ logging/log4php/trunk/src/test/php/bootstrap.php Tue Feb 28 07:49:21 2012
@@ -24,6 +24,9 @@
 
 error_reporting(E_ALL | E_STRICT); 
 
+// Required for testing logging of sessionID in pattern layout
+session_start();
+
 date_default_timezone_set('Europe/London');
 
 // Define a temp dir where tests may write to

Modified: logging/log4php/trunk/src/test/php/helpers/LoggerPatternParserTest.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/test/php/helpers/LoggerPatternParserTest.php?rev=1294503&r1=1294502&r2=1294503&view=diff
==============================================================================
--- logging/log4php/trunk/src/test/php/helpers/LoggerPatternParserTest.php (original)
+++ logging/log4php/trunk/src/test/php/helpers/LoggerPatternParserTest.php Tue Feb 28 07:49:21 2012
@@ -31,25 +31,25 @@
 class LoggerPatternParserTest extends PHPUnit_Framework_TestCase {
         
     public function testErrorLayout() {
-		$event = new LoggerLoggingEvent("LoggerLayoutXml", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-		$expected = 'ERROR TEST : testmessage in NA at NA'.PHP_EOL;
+// 		$event = new LoggerLoggingEvent("LoggerLayoutXml", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
+// 		$expected = 'ERROR TEST : testmessage in NA at NA'.PHP_EOL;
 		
-		$patternParser = new LoggerPatternParser("%-5p %c %X{username}: %m in %F at %L%n");
-		$c = $patternParser->parse();
+// 		$patternParser = new LoggerPatternParser("%-5p %c %X{username}: %m in %F at %L%n");
+// 		$c = $patternParser->parse();
 		
-		$actual = '';
-		$c->format($actual, $event);
+// 		$actual = '';
+// 		$c->format($actual, $event);
 //		self::assertEquals($expected, $actual);
 
     }
     
     public function testClassname() {
-		$event = new LoggerLoggingEvent("MyClass", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-		$expected = 'MyClass';
-		$patternParser = new LoggerPatternParser("%C");
-		$c = $patternParser->parse();
-		$actual = '';
-		$c->format($actual, $event);
-		self::assertEquals($expected, $actual);
+// 		$event = new LoggerLoggingEvent("MyClass", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
+// 		$expected = 'MyClass';
+// 		$patternParser = new LoggerPatternParser("%C");
+// 		$c = $patternParser->parse();
+// 		$actual = '';
+// 		$c->format($actual, $event);
+// 		self::assertEquals($expected, $actual);
     }
 }

Added: logging/log4php/trunk/src/test/php/helpers/LoggerUtilsTest.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/test/php/helpers/LoggerUtilsTest.php?rev=1294503&view=auto
==============================================================================
--- logging/log4php/trunk/src/test/php/helpers/LoggerUtilsTest.php (added)
+++ logging/log4php/trunk/src/test/php/helpers/LoggerUtilsTest.php Tue Feb 28 07:49:21 2012
@@ -0,0 +1,88 @@
+<?php
+/**
+ * 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.
+ *
+ * @category   tests
+ * @package    log4php
+ * @subpackage helpers
+ * @license    http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @version    SVN: $Id$
+ * @link       http://logging.apache.org/log4php
+ */
+
+/**
+ * @group helpers
+ */
+class LoggerUtilsTest extends PHPUnit_Framework_TestCase {
+	
+	public function testShorten() {
+		$name = 'org\\apache\\logging\\log4php\\Foo';
+		
+		$actual = LoggerUtils::shortenClassName($name, null);
+		self::assertSame($name, $actual);
+		
+		$actual = LoggerUtils::shortenClassName($name, 0);
+		self::assertSame('Foo', $actual);
+		
+		$actual = LoggerUtils::shortenClassName($name, 5);
+		self::assertSame('o\\a\\l\\l\\Foo', $actual);
+		
+		$actual = LoggerUtils::shortenClassName($name, 16);
+		self::assertSame('o\\a\\l\\l\\Foo', $actual);
+		
+		$actual = LoggerUtils::shortenClassName($name, 17);
+		self::assertSame('o\\a\\l\\log4php\\Foo', $actual);
+		
+		$actual = LoggerUtils::shortenClassName($name, 25);
+		self::assertSame('o\\a\\logging\\log4php\\Foo', $actual);
+		
+		$actual = LoggerUtils::shortenClassName($name, 28);
+		self::assertSame('o\\apache\\logging\\log4php\\Foo', $actual);
+		
+		$actual = LoggerUtils::shortenClassName($name, 30);
+		self::assertSame('org\\apache\\logging\\log4php\\Foo', $actual);
+	}
+	
+	/** Dot separated notation must be supported for legacy reasons. */
+	public function testShortenWithDots() {
+		$name = 'org.apache.logging.log4php.Foo';
+	
+		$actual = LoggerUtils::shortenClassName($name, null);
+		self::assertSame($name, $actual);
+	
+		$actual = LoggerUtils::shortenClassName($name, 0);
+		self::assertSame('Foo', $actual);
+	
+		$actual = LoggerUtils::shortenClassName($name, 5);
+		self::assertSame('o\a\l\l\Foo', $actual);
+	
+		$actual = LoggerUtils::shortenClassName($name, 16);
+		self::assertSame('o\a\l\l\Foo', $actual);
+	
+		$actual = LoggerUtils::shortenClassName($name, 17);
+		self::assertSame('o\a\l\log4php\Foo', $actual);
+	
+		$actual = LoggerUtils::shortenClassName($name, 25);
+		self::assertSame('o\a\logging\log4php\Foo', $actual);
+	
+		$actual = LoggerUtils::shortenClassName($name, 28);
+		self::assertSame('o\apache\logging\log4php\Foo', $actual);
+	
+		$actual = LoggerUtils::shortenClassName($name, 30);
+		self::assertSame('org\apache\logging\log4php\Foo', $actual);
+	}	
+	
+}
\ No newline at end of file

Modified: logging/log4php/trunk/src/test/php/layouts/LoggerLayoutPatternTest.php
URL: http://svn.apache.org/viewvc/logging/log4php/trunk/src/test/php/layouts/LoggerLayoutPatternTest.php?rev=1294503&r1=1294502&r2=1294503&view=diff
==============================================================================
--- logging/log4php/trunk/src/test/php/layouts/LoggerLayoutPatternTest.php (original)
+++ logging/log4php/trunk/src/test/php/layouts/LoggerLayoutPatternTest.php Tue Feb 28 07:49:21 2012
@@ -29,82 +29,26 @@
 class LoggerLayoutPatternTest extends PHPUnit_Framework_TestCase {
 
 	/** Pattern used for testing. */
-	private $pattern = "%d{Y-m-d H:i:s.u} %-5p %c (%C): %m in %F at %L%n";
+	private $pattern = "%-6level %logger: %msg from %class::%method() in %file at %line%n";
 	
-	public function testErrorLayout() {
-		$event = new LoggerLoggingEvent("LoggerLayoutXml", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-
-		$v = $this->formatEvent($event, $this->pattern);
-		$dt = $this->getEventDateTime($event);
-		$e = "$dt ERROR TEST (LoggerLayoutXml): testmessage in NA at NA".PHP_EOL;
-		self::assertEquals($e, $v);
-    }
-    
-    public function testWarnLayout() {
-		$event = new LoggerLoggingEvent("LoggerLayoutXml", new Logger("TEST"), LoggerLevel::getLevelWarn(), "testmessage");
-
-		$v = $this->formatEvent($event, $this->pattern);
-		$dt = $this->getEventDateTime($event);
-		$e = "$dt WARN  TEST (LoggerLayoutXml): testmessage in NA at NA".PHP_EOL;
-		self::assertEquals($e, $v);
-    }
-    
-    public function testInfoLayout() {
-		$event = new LoggerLoggingEvent("LoggerLayoutXml", new Logger("TEST"), LoggerLevel::getLevelInfo(), "testmessage");
-
-		$v = $this->formatEvent($event, $this->pattern);
-		$dt = $this->getEventDateTime($event);
-		$e = "$dt INFO  TEST (LoggerLayoutXml): testmessage in NA at NA".PHP_EOL;
-		self::assertEquals($e, $v);
-    }
-    
-    public function testDebugLayout() {
-		$event = new LoggerLoggingEvent("LoggerLayoutXml", new Logger("TEST"), LoggerLevel::getLevelDebug(), "testmessage");
-
-		$v = $this->formatEvent($event, $this->pattern);
-		$dt = $this->getEventDateTime($event);
-		$e = "$dt DEBUG TEST (LoggerLayoutXml): testmessage in NA at NA".PHP_EOL;
-		self::assertEquals($e, $v);
-    }
-    
-    public function testTraceLayout() {
-		$event = new LoggerLoggingEvent("LoggerLayoutXml2", new Logger("TEST"), LoggerLevel::getLevelTrace(), "testmessage");
+	public function testComplexLayout() {
 		
-		$v = $this->formatEvent($event, $this->pattern);
-		$dt = $this->getEventDateTime($event);
-		$e = "$dt TRACE TEST (LoggerLayoutXml2): testmessage in NA at NA".PHP_EOL;
-		self::assertEquals($e, $v);
-    }
-    
-    public function testClassnamePattern() {
-		$event = new LoggerLoggingEvent("LoggerLayoutPatternTest", new Logger("TEST"), LoggerLevel::getLevelError(), "testmessage");
-
-		$v = $this->formatEvent($event, '%C');
+		$config = LoggerTestHelper::getEchoPatternConfig($this->pattern);
+		Logger::configure($config);
 		
-		$dt = $this->getEventDateTime($event);
-		$e = "LoggerLayoutPatternTest";
-	
-		self::assertEquals($e, $v);
-    }
-    
-    /** 
-     *  Returns the datetime of an event in "Y-m-d H:i:s.u" format. This is required because
-     *  the PHP date() function does not handle the microseconds on windows (returns zeros).  
-     *  
-     *  @see http://www.php.net/manual/en/function.date.php#93752
-     */
-    private function getEventDateTime($event) {
-    	
-		$ts = $event->getTimeStamp();
-		$micros = round(($ts - floor($ts)) * 1000); // microseconds to 3 decimal places
-		$micros = str_pad($micros, 3, '0', STR_PAD_LEFT);
-		return date('Y-m-d H:i:s', $ts).".$micros";
+		ob_start();
+		$log = Logger::getLogger('LoggerTest');
+		$log->error("my message"); $line = __LINE__;
+		$actual = ob_get_contents();
+		ob_end_clean();
+		
+		$file = __FILE__;
+		$class = __CLASS__;
+		$method = __FUNCTION__;
+		
+		$expected = "ERROR  LoggerTest: my message from $class::$method() in $file at $line" . PHP_EOL;
+		self::assertSame($expected, $actual);
+		
+		Logger::resetConfiguration();
     }
-    
-	private function formatEvent($event, $pattern) {
-		$layout = new LoggerLayoutPattern();
-		$layout->setConversionPattern($pattern);
-		return $layout->format($event);
-	}
-    
 }



Mime
View raw message