diff --git a/libraries/log4php.debug/Logger.php b/libraries/log4php.debug/Logger.php
index 26d22606697c7dcba62b7f37bc2f45f0bebff765..1bc53bcdddf278d9560dccfd6263b6cc2a8a85d8 100644
--- a/libraries/log4php.debug/Logger.php
+++ b/libraries/log4php.debug/Logger.php
@@ -36,7 +36,7 @@ require dirname(__FILE__) . '/LoggerAutoloader.php';
  * 
  * @package    log4php
  * @license	   http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version	   SVN: $Id: Logger.php 1241439 2012-02-07 12:17:21Z ihabunek $
+ * @version	   SVN: $Id: Logger.php 1395241 2012-10-07 08:28:53Z ihabunek $
  * @link	   http://logging.apache.org/log4php
  */
 class Logger {
@@ -170,7 +170,34 @@ class Logger {
 	 */
 	public function log(LoggerLevel $level, $message, $throwable = null) {
 		if($this->isEnabledFor($level)) {
-			$this->forcedLog($this->fqcn, $throwable, $level, $message);
+			$event = new LoggerLoggingEvent($this->fqcn, $this, $level, $message, null, $throwable);
+			$this->callAppenders($event);
+		}
+		
+		// Forward the event upstream if additivity is turned on
+		if(isset($this->parent) && $this->getAdditivity()) {
+			
+			// Use the event if already created
+			if (isset($event)) {
+				$this->parent->logEvent($event);
+			} else {
+				$this->parent->log($level, $message, $throwable);
+			}
+		}
+	}
+	
+	/**
+	 * Logs an already prepared logging event object. 
+	 * @param LoggerLoggingEvent $event
+	 */
+	public function logEvent(LoggerLoggingEvent $event) {
+		if($this->isEnabledFor($event->getLevel())) {
+			$this->callAppenders($event);
+		}
+		
+		// Forward the event upstream if additivity is turned on
+		if(isset($this->parent) && $this->getAdditivity()) {
+			$this->parent->logEvent($event);
 		}
 	}
 	
@@ -202,11 +229,24 @@ class Logger {
 	 * @param mixed $message message to log
 	 */
 	public function forcedLog($fqcn, $throwable, LoggerLevel $level, $message) {
-		if (!($throwable instanceof Exception)) {
-			$throwable = null;
+		$event = new LoggerLoggingEvent($fqcn, $this, $level, $message, null, $throwable);
+		$this->callAppenders($event);
+		
+		// Forward the event upstream if additivity is turned on
+		if(isset($this->parent) && $this->getAdditivity()) {
+			$this->parent->logEvent($event);
 		}
-		$this->callAppenders(new LoggerLoggingEvent($fqcn, $this, $level, $message, null, $throwable));
-	} 
+	}
+
+	/**
+	 * Forwards the given logging event to all linked appenders.
+	 * @param LoggerLoggingEvent $event
+	 */
+	public function callAppenders($event) {
+		foreach($this->appenders as $appender) {
+			$appender->doAppend($event);
+		}
+	}
 	
 	// ******************************************
 	// *** Checker methods                    ***
@@ -304,22 +344,6 @@ class Logger {
 		}
 	}
 	
-	/**
-	 * Forwards the given logging event to all linked appenders.
-	 * @param LoggerLoggingEvent $event 
-	 */
-	public function callAppenders($event) {
-		// Forward the event to each linked appender
-		foreach($this->appenders as $appender) {
-			$appender->doAppend($event);
-		}
-		
-		// Forward the event upstream if additivity is turned on
-		if(isset($this->parent) && $this->getAdditivity()) {
-			$this->parent->callAppenders($event);
-		}
-	}
-	
 	/**
 	 * Returns the appenders linked to this logger as an array.
 	 * @return array collection of appender names
@@ -376,9 +400,12 @@ class Logger {
 	/**
 	 * Set the Logger level.
 	 *
-	 * @param LoggerLevel $level the level to set
+	 * Use LoggerLevel::getLevelXXX() methods to get a LoggerLevel object, e.g.
+	 * <code>$logger->setLevel(LoggerLevel::getLevelInfo());</code>
+	 *
+	 * @param LoggerLevel $level The level to set, or NULL to clear the logger level.
 	 */
-	public function setLevel($level) {
+	public function setLevel(LoggerLevel $level = null) {
 		$this->level = $level;
 	}
 	
@@ -390,9 +417,8 @@ class Logger {
 	 */
 	public function isAttached(LoggerAppender $appender) {
 		return isset($this->appenders[$appender->getName()]);
-	} 
-		   
-
+	}
+	
 	/**
 	 * Sets the parent logger.
 	 * @param Logger $logger
@@ -567,5 +593,4 @@ class Logger {
 	private static function isInitialized() {
 		return self::$initialized;
 	}
-	
 }
diff --git a/libraries/log4php.debug/LoggerAppender.php b/libraries/log4php.debug/LoggerAppender.php
index 923fc751f8606fb27a5a9502f3480e93b8c5072d..aef8a78fe1202c396d508557fb09d7dd6bd87b90 100644
--- a/libraries/log4php.debug/LoggerAppender.php
+++ b/libraries/log4php.debug/LoggerAppender.php
@@ -21,7 +21,7 @@
 /**
  * Abstract class that defines output logs strategies.
  *
- * @version $Revision: 1240469 $
+ * @version $Revision: 1374777 $
  * @package log4php
  */
 abstract class LoggerAppender extends LoggerConfigurable {
@@ -75,24 +75,23 @@ abstract class LoggerAppender extends LoggerConfigurable {
 	 */
 	public function __construct($name = '') {
 		$this->name = $name;
-		
-		// Closes the appender on shutdown. Better than a destructor because
-		// it will be called even if a fatal error occurs (destructor won't).
-		register_shutdown_function(array($this, 'close'));
-		
+
 		if ($this->requiresLayout) {
 			$this->layout = $this->getDefaultLayout();
 		}
 	}
 	
+	public function __destruct() {
+		$this->close();
+	}
+	
 	/**
 	 * Returns the default layout for this appender. Can be overriden by 
 	 * derived appenders.
 	 * 
 	 * @return LoggerLayout
 	 */
-	public function getDefaultLayout()
-	{
+	public function getDefaultLayout() {
 		return new LoggerLayoutSimple();
 	}
 	
@@ -148,12 +147,12 @@ abstract class LoggerAppender extends LoggerConfigurable {
 			return;
 		}
 
-		$f = $this->getFirstFilter();
-		while($f !== null) {
-			switch ($f->decide($event)) {
+		$filter = $this->getFirstFilter();
+		while($filter !== null) {
+			switch ($filter->decide($event)) {
 				case LoggerFilter::DENY: return;
 				case LoggerFilter::ACCEPT: return $this->append($event);
-				case LoggerFilter::NEUTRAL: $f = $f->getNext();
+				case LoggerFilter::NEUTRAL: $filter = $filter->getNext();
 			}
 		}
 		$this->append($event);
diff --git a/libraries/log4php.debug/LoggerAppenderPool.php b/libraries/log4php.debug/LoggerAppenderPool.php
index a2266f951ab0aa6986f13bb263a616c3078b02fe..7b5f539dfff83da0d33ac252743e142e346b5b3a 100644
--- a/libraries/log4php.debug/LoggerAppenderPool.php
+++ b/libraries/log4php.debug/LoggerAppenderPool.php
@@ -26,7 +26,7 @@
  * appender can be linked to multiple loggers. This makes sure duplicate 
  * appenders are not created.
  *
- * @version $Revision: 795727 $
+ * @version $Revision: 1350602 $
  * @package log4php
  */
 class LoggerAppenderPool {
@@ -39,8 +39,7 @@ class LoggerAppenderPool {
 	 * The appender must be named for this operation. 
 	 * @param LoggerAppender $appender
 	 */
-	public static function add(LoggerAppender $appender)
-	{
+	public static function add(LoggerAppender $appender) {
 		$name = $appender->getName();
 		
 		if(empty($name)) {
diff --git a/libraries/log4php.debug/LoggerAutoloader.php b/libraries/log4php.debug/LoggerAutoloader.php
index 225757cb85e76e3412145048c6e52d0ecef6a788..c6049d587e2f75b81fb0bd9003d659d28c6def4b 100644
--- a/libraries/log4php.debug/LoggerAutoloader.php
+++ b/libraries/log4php.debug/LoggerAutoloader.php
@@ -29,7 +29,7 @@ spl_autoload_register(array('LoggerAutoloader', 'autoload'));
  * 
  * @package log4php
  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
+ * @version $Revision: 1394956 $
  */
 class LoggerAutoloader {
 	
@@ -42,6 +42,7 @@ class LoggerAutoloader {
 		'LoggerConfigurable' => '/LoggerConfigurable.php',
 		'LoggerConfigurator' => '/LoggerConfigurator.php',
 		'LoggerException' => '/LoggerException.php',
+		'LoggerFilter' => '/LoggerFilter.php',
 		'LoggerHierarchy' => '/LoggerHierarchy.php',
 		'LoggerLevel' => '/LoggerLevel.php',
 		'LoggerLocationInfo' => '/LoggerLocationInfo.php',
@@ -52,7 +53,7 @@ class LoggerAutoloader {
 		'LoggerReflectionUtils' => '/LoggerReflectionUtils.php',
 		'LoggerRoot' => '/LoggerRoot.php',
 		'LoggerThrowableInformation' => '/LoggerThrowableInformation.php',
-
+		
 		// Appenders
 		'LoggerAppenderConsole' => '/appenders/LoggerAppenderConsole.php',
 		'LoggerAppenderDailyFile' => '/appenders/LoggerAppenderDailyFile.php',
@@ -62,6 +63,7 @@ class LoggerAutoloader {
 		'LoggerAppenderMailEvent' => '/appenders/LoggerAppenderMailEvent.php',
 		'LoggerAppenderMongoDB' => '/appenders/LoggerAppenderMongoDB.php',
 		'LoggerAppenderNull' => '/appenders/LoggerAppenderNull.php',
+		'LoggerAppenderFirePHP' => '/appenders/LoggerAppenderFirePHP.php',
 		'LoggerAppenderPDO' => '/appenders/LoggerAppenderPDO.php',
 		'LoggerAppenderPhp' => '/appenders/LoggerAppenderPhp.php',
 		'LoggerAppenderRollingFile' => '/appenders/LoggerAppenderRollingFile.php',
@@ -76,7 +78,6 @@ class LoggerAutoloader {
 		'LoggerConfiguratorDefault' => '/configurators/LoggerConfiguratorDefault.php',
 
 		// Filters
-		'LoggerFilter' => '/LoggerFilter.php',
 		'LoggerFilterDenyAll' => '/filters/LoggerFilterDenyAll.php',
 		'LoggerFilterLevelMatch' => '/filters/LoggerFilterLevelMatch.php',
 		'LoggerFilterLevelRange' => '/filters/LoggerFilterLevelRange.php',
@@ -86,18 +87,34 @@ class LoggerAutoloader {
 		'LoggerFormattingInfo' => '/helpers/LoggerFormattingInfo.php',
 		'LoggerOptionConverter' => '/helpers/LoggerOptionConverter.php',
 		'LoggerPatternParser' => '/helpers/LoggerPatternParser.php',
+		'LoggerUtils' => '/helpers/LoggerUtils.php',
+	
+		// Pattern converters
+		'LoggerPatternConverter' => '/pattern/LoggerPatternConverter.php',
+		'LoggerPatternConverterClass' => '/pattern/LoggerPatternConverterClass.php',
+		'LoggerPatternConverterCookie' => '/pattern/LoggerPatternConverterCookie.php',
+		'LoggerPatternConverterDate' => '/pattern/LoggerPatternConverterDate.php',
+		'LoggerPatternConverterEnvironment' => '/pattern/LoggerPatternConverterEnvironment.php',
+		'LoggerPatternConverterFile' => '/pattern/LoggerPatternConverterFile.php',
+		'LoggerPatternConverterLevel' => '/pattern/LoggerPatternConverterLevel.php',
+		'LoggerPatternConverterLine' => '/pattern/LoggerPatternConverterLine.php',
+		'LoggerPatternConverterLiteral' => '/pattern/LoggerPatternConverterLiteral.php',
+		'LoggerPatternConverterLocation' => '/pattern/LoggerPatternConverterLocation.php',
+		'LoggerPatternConverterLogger' => '/pattern/LoggerPatternConverterLogger.php',
+		'LoggerPatternConverterMDC' => '/pattern/LoggerPatternConverterMDC.php',
+		'LoggerPatternConverterMessage' => '/pattern/LoggerPatternConverterMessage.php',
+		'LoggerPatternConverterMethod' => '/pattern/LoggerPatternConverterMethod.php',
+		'LoggerPatternConverterNDC' => '/pattern/LoggerPatternConverterNDC.php',
+		'LoggerPatternConverterNewLine' => '/pattern/LoggerPatternConverterNewLine.php',
+		'LoggerPatternConverterProcess' => '/pattern/LoggerPatternConverterProcess.php',
+		'LoggerPatternConverterRelative' => '/pattern/LoggerPatternConverterRelative.php',
+		'LoggerPatternConverterRequest' => '/pattern/LoggerPatternConverterRequest.php',
+		'LoggerPatternConverterServer' => '/pattern/LoggerPatternConverterServer.php',
+		'LoggerPatternConverterSession' => '/pattern/LoggerPatternConverterSession.php',
+		'LoggerPatternConverterSessionID' => '/pattern/LoggerPatternConverterSessionID.php',
+		'LoggerPatternConverterSuperglobal' => '/pattern/LoggerPatternConverterSuperglobal.php',
+		'LoggerPatternConverterThrowable' => '/pattern/LoggerPatternConverterThrowable.php',
 		
-		// Converters
-		'LoggerBasicPatternConverter' => '/helpers/LoggerBasicPatternConverter.php',
-		'LoggerCategoryPatternConverter' => '/helpers/LoggerCategoryPatternConverter.php',
-		'LoggerClassNamePatternConverter' => '/helpers/LoggerClassNamePatternConverter.php',
-		'LoggerDatePatternConverter' => '/helpers/LoggerDatePatternConverter.php',
-		'LoggerLiteralPatternConverter' => '/helpers/LoggerLiteralPatternConverter.php',
-		'LoggerLocationPatternConverter' => '/helpers/LoggerLocationPatternConverter.php',
-		'LoggerMDCPatternConverter' => '/helpers/LoggerMDCPatternConverter.php',
-		'LoggerNamedPatternConverter' => '/helpers/LoggerNamedPatternConverter.php',
-		'LoggerPatternConverter' => '/helpers/LoggerPatternConverter.php',
-
 		// Layouts
 		'LoggerLayoutHtml' => '/layouts/LoggerLayoutHtml.php',
 		'LoggerLayoutPattern' => '/layouts/LoggerLayoutPattern.php',
@@ -110,9 +127,9 @@ class LoggerAutoloader {
 		'LoggerRendererDefault' => '/renderers/LoggerRendererDefault.php',
 		'LoggerRendererException' => '/renderers/LoggerRendererException.php',
 		'LoggerRendererMap' => '/renderers/LoggerRendererMap.php',
-		'LoggerRendererObject' => '/renderers/LoggerRendererObject.php',
+		'LoggerRenderer' => '/renderers/LoggerRenderer.php',
 	);
-
+	
 	/**
 	 * Loads a class.
 	 * @param string $className The name of the class to load.
diff --git a/libraries/log4php.debug/LoggerConfigurable.php b/libraries/log4php.debug/LoggerConfigurable.php
index 7f54e6fa42667b4e3195c652aaeecb1faae621ac..675037f69a360d594b5f4183cb4c3f4a383918d8 100644
--- a/libraries/log4php.debug/LoggerConfigurable.php
+++ b/libraries/log4php.debug/LoggerConfigurable.php
@@ -99,7 +99,8 @@ abstract class LoggerConfigurable {
 			}
 		} else {
 			try {
-				$this->$property = LoggerOptionConverter::toStringEx($value);
+				$value = LoggerOptionConverter::toStringEx($value);
+				$this->$property = LoggerOptionConverter::substConstants($value);
 			} catch (Exception $ex) {
 				$value = var_export($value, true);
 				$this->warn("Invalid value given for '$property' property: [$value]. Expected a string. Property not changed.");
@@ -113,7 +114,3 @@ abstract class LoggerConfigurable {
 		trigger_error("log4php: $class: $message", E_USER_WARNING);
 	}
 }
-
-
-
-?>
\ No newline at end of file
diff --git a/libraries/log4php.debug/LoggerException.php b/libraries/log4php.debug/LoggerException.php
index 1b9211a40fbbbad8a5208dca4dfd5bb77eeebd8e..f4edb21a30cb6a67727ae96276f525a6a3142cbf 100644
--- a/libraries/log4php.debug/LoggerException.php
+++ b/libraries/log4php.debug/LoggerException.php
@@ -21,7 +21,7 @@
 /**
  * LoggerException class
  *
- * @version $Revision: 771547 $
+ * @version $Revision: 1334369 $
  * @package log4php
  */
 class LoggerException extends Exception {
diff --git a/libraries/log4php.debug/LoggerHierarchy.php b/libraries/log4php.debug/LoggerHierarchy.php
index e7dd46d7279e884de660ddcca4e077e7c54610c5..05a52afe180721b4cf781c315f0b00ac3d169433 100644
--- a/libraries/log4php.debug/LoggerHierarchy.php
+++ b/libraries/log4php.debug/LoggerHierarchy.php
@@ -44,7 +44,7 @@
  * to the provision node. Other descendants of the same ancestor add
  * themselves to the previously created provision node.</p>
  *
- * @version $Revision: 1163124 $
+ * @version $Revision: 1394956 $
  * @package log4php
  */
 class LoggerHierarchy {
@@ -56,7 +56,7 @@ class LoggerHierarchy {
 	 * The root logger.
 	 * @var RootLogger 
 	 */
-	protected $root = null;
+	protected $root;
 	
 	/** 
 	 * The logger renderer map.
@@ -157,9 +157,6 @@ class LoggerHierarchy {
 	 * @return LoggerRoot
 	 */ 
 	public function getRootLogger() {
-		if(!isset($this->root) or $this->root == null) {
-			$this->root = new LoggerRoot();
-		}
 		return $this->root;
 	}
 	 
@@ -207,7 +204,7 @@ class LoggerHierarchy {
 			$logger->removeAllAppenders();
 		}
 		
-		$this->rendererMap->clear();
+		$this->rendererMap->reset();
 		LoggerAppenderPool::clear();
 	}
 	
@@ -237,4 +234,24 @@ class LoggerHierarchy {
 			$logger->removeAllAppenders();
 		}
 	}
+	
+	/**
+	 * Prints the current Logger hierarchy tree. Useful for debugging.
+	 */
+	public function printHierarchy() {
+		$this->printHierarchyInner($this->getRootLogger(), 0);
+	}
+	
+	private function printHierarchyInner(Logger $current, $level) {
+		for ($i = 0; $i < $level; $i++) {
+			echo ($i == $level - 1) ? "|--" : "|  ";
+		}
+		echo $current->getName() . "\n";
+		
+		foreach($this->loggers as $logger) {
+			if ($logger->getParent() == $current) {
+				$this->printHierarchyInner($logger, $level + 1);
+			}
+		}
+	}
 } 
diff --git a/libraries/log4php.debug/LoggerLevel.php b/libraries/log4php.debug/LoggerLevel.php
index a4238b6845ae5a803a35e4b6b3b198eb3b8962af..a76976f5925d157fe839116e2d828ea8a1255dd1 100644
--- a/libraries/log4php.debug/LoggerLevel.php
+++ b/libraries/log4php.debug/LoggerLevel.php
@@ -27,7 +27,7 @@
  * <p>The <i>LoggerLevel</i> class may be subclassed to define a larger
  * level set.</p>
  *
- * @version $Revision: 1230524 $
+ * @version $Revision: 1379729 $
  * @package log4php
  * @since 0.5
  */
@@ -175,7 +175,7 @@ class LoggerLevel {
 	}
 	
 	/**
-	 * Return the syslog equivalent of this priority as an integer.
+	 * Return the syslog equivalent of this level as an integer.
 	 * @return integer
 	 */
 	public function getSyslogEquivalent() {
diff --git a/libraries/log4php.debug/LoggerLocationInfo.php b/libraries/log4php.debug/LoggerLocationInfo.php
index 6138590faebc8468d79c4af294ec3561d0f9803a..e6a8efea6e0a6bfb405c41d4d805cde3f2513088 100644
--- a/libraries/log4php.debug/LoggerLocationInfo.php
+++ b/libraries/log4php.debug/LoggerLocationInfo.php
@@ -21,42 +21,44 @@
 /**
  * The internal representation of caller location information.
  *
- * @version $Revision: 822448 $
+ * @version $Revision: 1379738 $
  * @package log4php
  * @since 0.3
  */
 class LoggerLocationInfo {
-	/**
-	 * When location information is not available the constant
-	 * <i>NA</i> is returned. Current value of this string
-	 * constant is <b>?</b>.  
-	 */
+	
+	/** The value to return when the location information is not available. */
 	const LOCATION_INFO_NA = 'NA';
 	
 	/**
-	* @var string Caller's line number.
-	*/
-	protected $lineNumber = null;
+	 * Caller line number.
+	 * @var integer 
+	 */
+	protected $lineNumber;
 	
 	/**
-	* @var string Caller's file name.
-	*/
-	protected $fileName = null;
+	 * Caller file name.
+	 * @var string 
+	 */
+	protected $fileName;
 	
 	/**
-	* @var string Caller's fully qualified class name.
-	*/
-	protected $className = null;
+	 * Caller class name.
+	 * @var string 
+	 */
+	protected $className;
 	
 	/**
-	* @var string Caller's method name.
-	*/
-	protected $methodName = null;
+	 * Caller method name.
+	 * @var string 
+	 */
+	protected $methodName;
 	
 	/**
-	* @var string 
-	*/
-	protected $fullInfo = null;
+	 * All the information combined.
+	 * @var string 
+	 */
+	protected $fullInfo;
 
 	/**
 	 * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
@@ -73,36 +75,27 @@ class LoggerLocationInfo {
 			'(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
 	}
 
+	/** Returns the caller class name. */
 	public function getClassName() {
 		return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className; 
 	}
 
-	/**
-	 *	Return the file name of the caller.
-	 *	<p>This information is not always available.
-	 */
+	/** Returns the caller file name. */
 	public function getFileName() {
 		return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName; 
 	}
 
-	/**
-	 *	Returns the line number of the caller.
-	 *	<p>This information is not always available.
-	 */
+	/** Returns the caller line number. */
 	public function getLineNumber() {
 		return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber; 
 	}
 
-	/**
-	 *	Returns the method name of the caller.
-	 */
+	/** Returns the caller method name. */
 	public function getMethodName() {
 		return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName; 
 	}
 
-	/**
-	 *	Returns the full information of the caller.
-	 */
+	/** Returns the full information of the caller. */
 	public function getFullInfo() {
 		return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
 	}
diff --git a/libraries/log4php.debug/LoggerLoggingEvent.php b/libraries/log4php.debug/LoggerLoggingEvent.php
index 7e38972e92f27163bcf371780cd045a132978287..f0a47382f80baaccf101fd2f8b35e7421078e993 100644
--- a/libraries/log4php.debug/LoggerLoggingEvent.php
+++ b/libraries/log4php.debug/LoggerLoggingEvent.php
@@ -21,7 +21,7 @@
 /**
  * The internal representation of logging event.
  *
- * @version $Revision: 1222216 $
+ * @version $Revision: 1382273 $
  * @package log4php
  */
 class LoggerLoggingEvent {
@@ -36,7 +36,7 @@ class LoggerLoggingEvent {
 	/**
 	* @var Logger reference
 	*/
-	private $logger = null;
+	private $logger;
 	
 	/** 
 	 * The category (logger) name.
@@ -68,14 +68,6 @@ class LoggerLoggingEvent {
 	 */
 	private $ndcLookupRequired = true;
 	
-	/** 
-	 * Have we tried to do an MDC lookup? If we did, there is no need
-	 * to do it again.	Note that its value is always false when
-	 * serialized. See also the getMDC and getMDCCopy methods.
-	 * @var boolean	 
-	 */
-	private $mdcCopyLookupRequired = true;
-	
 	/** 
 	 * @var mixed The application supplied message of logging event. 
 	 */
@@ -86,14 +78,14 @@ class LoggerLoggingEvent {
 	 * objet rendering mechanism. At present renderedMessage == message.
 	 * @var string
 	 */
-	private $renderedMessage = null;
+	private $renderedMessage;
 	
 	/** 
 	 * The name of thread in which this logging event was generated.
 	 * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} 
 	 * @var mixed
 	 */
-	private $threadName = null;
+	private $threadName;
 	
 	/** 
 	* The number of seconds elapsed from 1/1/1970 until logging event
@@ -105,12 +97,12 @@ class LoggerLoggingEvent {
 	/** 
 	* @var LoggerLocationInfo Location information for the caller. 
 	*/
-	private $locationInfo = null;
+	private $locationInfo;
 	
 	/**
 	 * @var LoggerThrowableInformation log4php internal representation of throwable
 	 */
-	private $throwableInfo = null;
+	private $throwableInfo;
 	
 	/**
 	* Instantiate a LoggingEvent from the supplied parameters.
@@ -120,12 +112,12 @@ class LoggerLoggingEvent {
 	*
 	* @param string $fqcn name of the caller class.
 	* @param mixed $logger The {@link Logger} category of this event or the logger name.
-	* @param LoggerLevel $priority The level of this event.
+	* @param LoggerLevel $level The level of this event.
 	* @param mixed $message The message of this event.
 	* @param integer $timeStamp the timestamp of this logging event.
 	* @param Exception $throwable The throwable associated with logging event
 	*/
-	public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null, Exception $throwable = null) {
+	public function __construct($fqcn, $logger, LoggerLevel $level, $message, $timeStamp = null, $throwable = null) {
 		$this->fqcn = $fqcn;
 		if($logger instanceof Logger) {
 			$this->logger = $logger;
@@ -133,9 +125,9 @@ class LoggerLoggingEvent {
 		} else {
 			$this->categoryName = strval($logger);
 		}
-		$this->level = $priority;
+		$this->level = $level;
 		$this->message = $message;
-		if($timeStamp !== null && is_float($timeStamp)) {
+		if($timeStamp !== null && is_numeric($timeStamp)) {
 			$this->timeStamp = $timeStamp;
 		} else {
 			$this->timeStamp = microtime(true);
@@ -211,6 +203,14 @@ class LoggerLoggingEvent {
 		return $this->level;
 	}
 
+	/**
+	 * Returns the logger which created the event.
+	 * @return Logger
+	 */
+	public function getLogger() {
+		return $this->logger;
+	}
+	
 	/**
 	 * Return the name of the logger. Use this form instead of directly
 	 * accessing the {@link $categoryName} field.
@@ -222,19 +222,10 @@ class LoggerLoggingEvent {
 
 	/**
 	 * Return the message for this logging event.
-	 *
-	 * <p>Before serialization, the returned object is the message
-	 * passed by the user to generate the logging event. After
-	 * serialization, the returned value equals the String form of the
-	 * message possibly after object rendering.
 	 * @return mixed
 	 */
 	public function getMessage() {
-		if($this->message !== null) {
-			return $this->message;
-		} else {
-			return $this->getRenderedMessage();
-		}
+		return $this->message;
 	}
 
 	/**
@@ -305,8 +296,23 @@ class LoggerLoggingEvent {
 	}
 	
 	/**
-	 * Calculates the time of this event.
-	 * @return the time after event starttime when this event has occured
+	 * Returns the time in seconds passed from the beginning of execution to 
+	 * the time the event was constructed.
+	 * 
+	 * @return float Seconds with microseconds in decimals.
+	 */
+	public function getRelativeTime() {
+		return $this->timeStamp - self::$startTime;
+	}
+	
+	/**
+	 * Returns the time in milliseconds passed from the beginning of execution
+	 * to the time the event was constructed.
+	 * 
+	 * @deprecated This method has been replaced by getRelativeTime which 
+	 * 		does not perform unneccesary multiplication and formatting.
+	 * 
+	 * @return integer 
 	 */
 	public function getTime() {
 		$eventTime = $this->getTimeStamp();
diff --git a/libraries/log4php.debug/LoggerMDC.php b/libraries/log4php.debug/LoggerMDC.php
index 9f3f3008ee4ea6cb5abdca8268a9af6944e023ed..f5d328306478149802cf64de690e317d0587ee18 100644
--- a/libraries/log4php.debug/LoggerMDC.php
+++ b/libraries/log4php.debug/LoggerMDC.php
@@ -19,31 +19,17 @@
  */
 
 /**
- * The LoggerMDC class provides <i>mapped diagnostic contexts</i>.
+ * The LoggerMDC class provides _mapped diagnostic contexts_.
  * 
- * A <i>Mapped Diagnostic Context</i>, or
- * MDC in short, is an instrument for distinguishing interleaved log
- * output from different sources. Log output is typically interleaved
- * when a server handles multiple clients near-simultaneously.
+ * A Mapped Diagnostic Context, or MDC in short, is an instrument for 
+ * distinguishing interleaved log output from different sources. Log output 
+ * is typically interleaved when a server handles multiple clients 
+ * near-simultaneously.
  * 
  * This class is similar to the {@link LoggerNDC} class except that 
  * it is based on a map instead of a stack.
  * 
- * Example:
- * 
- * {@example ../../examples/php/mdc.php 19}<br>
- *
- * With the properties file:
- * 
- * {@example ../../examples/resources/mdc.properties 18}<br>
- * 
- * Will result in the following (notice the username "knut" in the output):
- * 
- * <pre>
- * 2009-09-13 18:48:28 DEBUG root knut: Testing MDC in src/examples/php/mdc.php at 23
- * </pre>
- * 
- * @version $Revision: 1212773 $
+ * @version $Revision: 1343630 $
  * @since 0.3
  * @package log4php
  */
@@ -66,28 +52,12 @@ class LoggerMDC {
 	/**
 	 * Returns the context value identified by the key parameter.
 	 *
-	 * Special key identifiers can be used to map values in the global $_SERVER
-	 * and $_ENV vars. To access them, use 'server.' or 'env.' followed by the 
-	 * desired var name as the key.
-	 *
 	 * @param string $key The key.
 	 * @return string The context or an empty string if no context found
 	 * 	for given key.
 	 */
 	public static function get($key) {
-		if(!empty($key)) {
-			if(strpos($key, 'server.') === 0) {
-				$varName = substr($key, 7);
-				return isset($_SERVER[$varName]) ? $_SERVER[$varName] : '';
-			} else if(strpos($key, 'env.') === 0) {
-				$varName = substr($key, 4);
-				$value = getenv($varName);
-				return ($value !== false) ? $value : '';
-			} else {
-				return isset(self::$map[$key]) ? self::$map[$key] : '';
-			}
-		}
-		return '';
+		return isset(self::$map[$key]) ? self::$map[$key] : '';
 	}
 
 	/**
diff --git a/libraries/log4php.debug/LoggerNDC.php b/libraries/log4php.debug/LoggerNDC.php
index 1521f3e61395a1479f8567a48ea0f1638233c07c..d77ea59ebb546bea47bd553f0d92f795223b08c7 100644
--- a/libraries/log4php.debug/LoggerNDC.php
+++ b/libraries/log4php.debug/LoggerNDC.php
@@ -89,7 +89,7 @@
  * 2009-09-13 19:04:27 DEBUG root : back and waiting for new connections in src/examples/php/ndc.php at 29
  * </pre>
  *	
- * @version $Revision: 1166187 $
+ * @version $Revision: 1350602 $
  * @package log4php 
  * @since 0.3
  */
@@ -153,14 +153,14 @@ class LoggerNDC {
 	 * context is available, then the empty string "" is returned.</p>
 	 * @return string The innermost diagnostic context.
 	 */
-	public static function peek(){
+	public static function peek() {
 		if(count(self::$stack) > 0) {
 			return end(self::$stack);
 		} else {
 			return '';
 		}
 	}
-  
+	
 	/**
 	 * Push new diagnostic context information for the current thread.
 	 *
diff --git a/libraries/log4php.debug/LoggerReflectionUtils.php b/libraries/log4php.debug/LoggerReflectionUtils.php
index 11573ecd495cf8672af2b748b2854272d2d24dfe..e04618560862d089989ce30e193e2c0457972588 100644
--- a/libraries/log4php.debug/LoggerReflectionUtils.php
+++ b/libraries/log4php.debug/LoggerReflectionUtils.php
@@ -65,7 +65,6 @@ class LoggerReflectionUtils {
 	 * @param array $properties An array containing keys and values.
 	 * @param string $prefix Only keys having the specified prefix will be set.
 	 */
-	 // TODO: check, if this is really useful
 	public function setProperties($properties, $prefix) {
 		$len = strlen($prefix);
 		reset($properties);
@@ -74,7 +73,7 @@ class LoggerReflectionUtils {
 				if(strpos($key, '.', ($len + 1)) > 0) {
 					continue;
 				}
-				$value = LoggerOptionConverter::findAndSubst($key, $properties);
+				$value = $properties[$key];
 				$key = substr($key, $len);
 				if($key == 'layout' and ($this->obj instanceof LoggerAppender)) {
 					continue;
diff --git a/libraries/log4php.debug/LoggerRoot.php b/libraries/log4php.debug/LoggerRoot.php
index 780b270480b671c29751d4e448b25f002378d23f..0ed27b46c040d643ed1c000a2648c56622c01438 100644
--- a/libraries/log4php.debug/LoggerRoot.php
+++ b/libraries/log4php.debug/LoggerRoot.php
@@ -21,7 +21,7 @@
 /**
  * The root logger.
  *
- * @version $Revision: 822448 $
+ * @version $Revision: 1343190 $
  * @package log4php
  * @see Logger
  */
@@ -31,7 +31,7 @@ class LoggerRoot extends Logger {
 	 *
 	 * @param integer $level initial log level
 	 */
-	public function __construct($level = null) {
+	public function __construct(LoggerLevel $level = null) {
 		parent::__construct('root');
 
 		if($level == null) {
@@ -43,28 +43,29 @@ class LoggerRoot extends Logger {
 	/**
 	 * @return LoggerLevel the level
 	 */
-	public function getChainedLevel() {
-		return parent::getLevel();
-	} 
+	public function getEffectiveLevel() {
+		return $this->getLevel();
+	}
 	
 	/**
-	 * Setting a null value to the level of the root category may have catastrophic results.
+	 * Override level setter to prevent setting the root logger's level to 
+	 * null. Root logger must always have a level.
+	 * 
 	 * @param LoggerLevel $level
 	 */
-	public function setLevel($level) {
-		if($level != null) {
+	public function setLevel(LoggerLevel $level = null) {
+		if (isset($level)) {
 			parent::setLevel($level);
-		}	 
+		} else {
+			trigger_error("log4php: Cannot set LoggerRoot level to null.", E_USER_WARNING);
+		}
 	}
 	
 	/**
-	 * Always returns false.
-	 * Because LoggerRoot has no parents, it returns false.
+	 * Override parent setter. Root logger cannot have a parent.
 	 * @param Logger $parent
-	 * @return boolean
 	 */
 	public function setParent(Logger $parent) {
-		return false;
+		trigger_error("log4php: LoggerRoot cannot have a parent.", E_USER_WARNING);
 	}
-
 }
diff --git a/libraries/log4php.debug/LoggerThrowableInformation.php b/libraries/log4php.debug/LoggerThrowableInformation.php
index 75511c98cad6d2b0258907f2869962ef0a721944..20bf758263e6b807edf66ba0ab333642ac4a3eb1 100644
--- a/libraries/log4php.debug/LoggerThrowableInformation.php
+++ b/libraries/log4php.debug/LoggerThrowableInformation.php
@@ -32,16 +32,13 @@ class LoggerThrowableInformation {
 	/** @var array Array of throwable messages */
 	private $throwableArray;
 	
-	/** @var Logger reference */
-	private $logger;
-	
 	/**
 	 * Create a new instance
 	 * 
 	 * @param $throwable - a throwable as a exception
 	 * @param $logger - Logger reference
 	 */
-	public function __construct(Exception $throwable)  {
+	public function __construct(Exception $throwable) {
 		$this->throwable = $throwable;
 	}
 	
@@ -61,16 +58,11 @@ class LoggerThrowableInformation {
 	 */
 	public function getStringRepresentation() {
 		if (!is_array($this->throwableArray)) {
-			$renderer = Logger::getHierarchy()->getRendererMap()->getByClassName(get_class($this->throwable));
+			$renderer = new LoggerRendererException();
 			
-			// TODO: why this?
-			if ($renderer instanceof LoggerRendererDefault) {
-				$renderer = new LoggerRendererException();
-			}
 			$this->throwableArray = explode("\n", $renderer->render($this->throwable));
 		}
 		
 		return $this->throwableArray;
 	}
 }
-?>
\ No newline at end of file
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderConsole.php b/libraries/log4php.debug/appenders/LoggerAppenderConsole.php
index f1e1052080f076d5f55847749a954e6c285822d9..6f380601e6887ab1ff7cd67a037afa9320dc7a79 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderConsole.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderConsole.php
@@ -14,70 +14,44 @@
  * 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
  */
 
 /**
- * ConsoleAppender appends log events to STDOUT or STDERR. 
+ * LoggerAppenderConsole appends log events either to the standard output 
+ * stream (php://stdout) or the standard error stream (php://stderr).
  * 
- * <p><b>Note</b>: Use this Appender with command-line php scripts. 
- * On web scripts this appender has no effects.</p>
+ * **Note**: Use this Appender with command-line php scripts. On web scripts 
+ * this appender has no effects.
  *
- * Configurable parameters of this appender are:
+ * This appender uses a layout.
  *
- * - layout     - The layout (required)
- * - target     - "stdout" or "stderr"
- * 
- * An example php file:
- * 
- * {@example ../../examples/php/appender_console.php 19}
- * 
- * An example configuration file:
+ * ## Configurable parameters: ##
  * 
- * {@example ../../examples/resources/appender_console.properties 18}
+ * - **target** - the target stream: "stdout" or "stderr"
  * 
- * @version $Revision: 1213283 $
+ * @version $Revision: 1343601 $
  * @package log4php
  * @subpackage appenders
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/console.html Appender documentation
  */
-class LoggerAppenderConsole extends LoggerAppender {
+ class LoggerAppenderConsole extends LoggerAppender {
 
+	/** The standard otuput stream.  */
 	const STDOUT = 'php://stdout';
+	
+	/** The standard error stream.*/
 	const STDERR = 'php://stderr';
 
-	/**
-	 * Can be 'php://stdout' or 'php://stderr'. But it's better to use keywords <b>STDOUT</b> and <b>STDERR</b> (case insensitive). 
-	 * Default is STDOUT
-	 * @var string
-	 */
+	/** The 'target' parameter. */
 	protected $target = self::STDOUT;
 	
 	/**
-	 * @var mixed the resource used to open stdout/stderr
+	 * Stream resource for the target stream.
+	 * @var resource
 	 */
 	protected $fp = null;
 
-	/**
-	 * Set console target.
-	 * @param mixed $value a constant or a string
-	 */
-	public function setTarget($value) {
-		$v = trim($value);
-		if ($v == self::STDOUT || strtoupper($v) == 'STDOUT') {
-			$this->target = self::STDOUT;
-		} elseif ($v == self::STDERR || strtoupper($v) == 'STDERR') {
-			$this->target = self::STDERR;
-		} else {
-			$value = var_export($value);
-			$this->warn("Invalid value given for 'target' property: [$value]. Property not set.");
-		}
-	}
-
-	public function getTarget() {
-		return $this->target;
-	}
-
 	public function activateOptions() {
 		$this->fp = fopen($this->target, 'w');
 		if(is_resource($this->fp) && $this->layout !== null) {
@@ -86,6 +60,7 @@ class LoggerAppenderConsole extends LoggerAppender {
 		$this->closed = (bool)is_resource($this->fp) === false;
 	}
 	
+	
 	public function close() {
 		if($this->closed != true) {
 			if (is_resource($this->fp) && $this->layout !== null) {
@@ -101,5 +76,28 @@ class LoggerAppenderConsole extends LoggerAppender {
 			fwrite($this->fp, $this->layout->format($event));
 		}
 	}
+	
+	/**
+	 * Sets the 'target' parameter.
+	 * @param string $target
+	 */
+	public function setTarget($target) {
+		$value = trim($target);
+		if ($value == self::STDOUT || strtoupper($value) == 'STDOUT') {
+			$this->target = self::STDOUT;
+		} elseif ($value == self::STDERR || strtoupper($value) == 'STDERR') {
+			$this->target = self::STDERR;
+		} else {
+			$target = var_export($target);
+			$this->warn("Invalid value given for 'target' property: [$target]. Property not set.");
+		}
+	}
+	
+	/**
+	 * Returns the value of the 'target' parameter.
+	 * @return string
+	 */
+	public function getTarget() {
+		return $this->target;
+	}
 }
-
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderDailyFile.php b/libraries/log4php.debug/appenders/LoggerAppenderDailyFile.php
index 157eb22f1b2db2749bede61ba958f3a9c4263452..af349aa9f3914fc373a0a8602a9e91fc4807e362 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderDailyFile.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderDailyFile.php
@@ -14,8 +14,6 @@
  * 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
  */
 
 /**
@@ -27,84 +25,106 @@
  *
  * This appender uses a layout.
  * 
- * Configurable parameters for this appender are:
- * - datePattern - The date format for the file name. Should be set before 
- *                 $file. Default value: "Ymd".
- * - file        - The path to the target log file. The filename should 
- *                 contain a '%s' which will be substituted by the date.
- * - append      - Sets if the appender should append to the end of the
- *                 file or overwrite content ("true" or "false"). Default 
- *                 value: true.
- * 
- * An example php file:
+ * ##Configurable parameters:##
  * 
- * {@example ../../examples/php/appender_dailyfile.php 19}
- *  
- * An example configuration file:
+ * - **datePattern** - Format for the date in the file path, follows formatting
+ *     rules used by the PHP date() function. Default value: "Ymd".
+ * - **file** - Path to the target file. Should contain a %s which gets 
+ *     substituted by the date.
+ * - **append** - If set to true, the appender will append to the file, 
+ *     otherwise the file contents will be overwritten. Defaults to true.
  * 
- * {@example ../../examples/resources/appender_dailyfile.properties 18}
- *
- * The above will create a file like: daily_20090908.log
- *
- * @version $Revision: 1213283 $
+ * @version $Revision: 1382274 $
  * @package log4php
  * @subpackage appenders
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/daily-file.html Appender documentation
  */
 class LoggerAppenderDailyFile extends LoggerAppenderFile {
 
 	/**
-	 * Format date. 
-	 * It follows the {@link PHP_MANUAL#date()} formatting rules and <b>should always be set before {@link $file} param</b>.
+	 * The 'datePattern' parameter.
+	 * Determines how date will be formatted in file name.
 	 * @var string
 	 */
 	protected $datePattern = "Ymd";
 	
 	/**
-	 * Sets date format for the file name.
-	 * @param string $datePattern a regular date() string format
+	 * Current date which was used when opening a file.
+	 * Used to determine if a rollover is needed when the date changes.
+	 * @var string
+	 */
+	protected $currentDate;
+
+	/** Additional validation for the date pattern. */
+	public function activateOptions() {
+		parent::activateOptions();
+	
+		if (empty($this->datePattern)) {
+			$this->warn("Required parameter 'datePattern' not set. Closing appender.");
+			$this->closed = true;
+			return;
+		}
+	}
+
+	/**
+	 * Appends a logging event.
+	 * 
+	 * If the target file changes because of passage of time (e.g. at midnight) 
+	 * the current file is closed. A new file, with the new date, will be 
+	 * opened by the write() method. 
+	 */
+	public function append(LoggerLoggingEvent $event) {
+		$eventDate = $this->getDate($event->getTimestamp());
+		
+		// Initial setting of current date
+		if (!isset($this->currentDate)) {
+			$this->currentDate = $eventDate;
+		} 
+		
+		// Check if rollover is needed
+		else if ($this->currentDate !== $eventDate) {
+			$this->currentDate = $eventDate;
+			
+			// Close the file if it's open.
+			// Note: $this->close() is not called here because it would set
+			//       $this->closed to true and the appender would not recieve
+			//       any more logging requests
+			if (is_resource($this->fp)) {
+				$this->write($this->layout->getFooter());
+				fclose($this->fp);
+			}
+			$this->fp = null;
+		}
+	
+		parent::append($event);
+	}
+	
+	/** Renders the date using the configured <var>datePattern<var>. */
+	protected function getDate($timestamp = null) {
+		return date($this->datePattern, $timestamp);
+	}
+	
+	/**
+	 * Determines target file. Replaces %s in file path with a date. 
+	 */
+	protected function getTargetFile() {
+		return str_replace('%s', $this->currentDate, $this->file);
+	}
+	
+	/**
+	 * Sets the 'datePattern' parameter.
+	 * @param string $datePattern
 	 */
 	public function setDatePattern($datePattern) {
 		$this->setString('datePattern', $datePattern);
 	}
 	
 	/**
-	 * @return string returns date format for the filename
+	 * Returns the 'datePattern' parameter.
+	 * @return string
 	 */
 	public function getDatePattern() {
 		return $this->datePattern;
 	}
-	
-	/** 
-	 * Similar to parent method, but but replaces "%s" in the file name with 
-	 * the current date in format specified by the 'datePattern' parameter.
-	 */ 
-	public function activateOptions() {
-		$fileName = $this->getFile();
-		$date = date($this->getDatePattern());
-		$fileName = sprintf($fileName, $date);
-		
-		if(!is_file($fileName)) {
-			$dir = dirname($fileName);
-			if(!is_dir($dir)) {
-				mkdir($dir, 0777, true);
-			}
-		}
-	
-		$this->fp = fopen($fileName, ($this->getAppend()? 'a':'w'));
-		if($this->fp) {
-			if(flock($this->fp, LOCK_EX)) {
-				if($this->getAppend()) {
-					fseek($this->fp, 0, SEEK_END);
-				}
-				fwrite($this->fp, $this->layout->getHeader());
-				flock($this->fp, LOCK_UN);
-				$this->closed = false;
-			} else {
-				// TODO: should we take some action in this case?
-				$this->closed = true;
-			}
-		} else {
-			$this->closed = true;
-		}
-	}
 }
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderEcho.php b/libraries/log4php.debug/appenders/LoggerAppenderEcho.php
index e53241432d62534b746db70113c37c32fc219d09..d66bdaf6336659b5a638daa9ccd7df1d32f3900c 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderEcho.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderEcho.php
@@ -14,34 +14,29 @@
  * 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
  */
 
 /**
- * LoggerAppenderEcho uses {@link PHP_MANUAL#echo echo} function to output events. 
- * 
- * <p>This appender requires a layout.</p>	
+ * LoggerAppenderEcho uses the PHP echo() function to output events. 
  * 
- * An example php file:
+ * This appender uses a layout.
  * 
- * {@example ../../examples/php/appender_echo.php 19}
+ * ## Configurable parameters: ##
  * 
- * An example configuration file:
- * 
- * {@example ../../examples/resources/appender_echo.properties 18}
- * 
- * The above example would print the following:
- * <pre>
- *    Tue Sep  8 22:44:55 2009,812 [6783] DEBUG appender_echo - Hello World!
- * </pre>
+ * - **htmlLineBreaks** - If set to true, a <br /> element will be inserted 
+ *     before each line break in the logged message. Default is false.
  *
- * @version $Revision: 1213283 $
+ * @version $Revision: 1337820 $
  * @package log4php
  * @subpackage appenders
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/echo.html Appender documentation
  */
 class LoggerAppenderEcho extends LoggerAppender {
-	/** boolean used internally to mark first append */
+	/** 
+	 * Used to mark first append. Set to false after first append.
+	 * @var boolean 
+	 */
 	protected $firstAppend = true;
 	
 	/** 
@@ -74,10 +69,18 @@ class LoggerAppenderEcho extends LoggerAppender {
 		} 
 	}
 	
+	/**
+	 * Sets the 'htmlLineBreaks' parameter.
+	 * @param boolean $value
+	 */
 	public function setHtmlLineBreaks($value) {
 		$this->setBoolean('htmlLineBreaks', $value);
 	}
-
+	
+	/**
+	 * Returns the 'htmlLineBreaks' parameter.
+	 * @returns boolean
+	 */
 	public function getHtmlLineBreaks() {
 		return $this->htmlLineBreaks;
 	}
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderFile.php b/libraries/log4php.debug/appenders/LoggerAppenderFile.php
index d1c9bbfb55b7cd14d6d78cf1a8f56f2558e4c3d7..12d44aa19e97ca205dbd86255df917bea6055a51 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderFile.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderFile.php
@@ -14,109 +14,167 @@
  * 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
  */
 
 /**
- * FileAppender appends log events to a file.
+ * LoggerAppenderFile appends log events to a file.
  *
  * This appender uses a layout.
  * 
- * Configurable parameters for this appender are:
- * - file      - The target file to write to
- * - filename  - The target file to write to (deprecated, use "file" instead)
- * - append    - Sets if the appender should append to the end of the file or overwrite content ("true" or "false")
- *
- * An example php file:
+ * ## Configurable parameters: ##
  * 
- * {@example ../../examples/php/appender_file.php 19}
+ * - **file** - Path to the target file. Relative paths are resolved based on 
+ *     the working directory.
+ * - **append** - If set to true, the appender will append to the file, 
+ *     otherwise the file contents will be overwritten.
  *
- * An example configuration file:
- * 
- * {@example ../../examples/resources/appender_file.properties 18}
- * 
- * @version $Revision: 1213663 $
+ * @version $Revision: 1382274 $
  * @package log4php
  * @subpackage appenders
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/file.html Appender documentation
  */
 class LoggerAppenderFile extends LoggerAppender {
 
 	/**
-	 * @var boolean if {@link $file} exists, appends events.
+	 * If set to true, the file is locked before appending. This allows 
+	 * concurrent access. However, appending without locking is faster so
+	 * it should be used where appropriate.
+	 * 
+	 * TODO: make this a configurable parameter
+	 * 
+	 * @var boolean
+	 */
+	protected $locking = true;
+	
+	/**
+	 * If set to true, appends to file. Otherwise overwrites it.
+	 * @var boolean
 	 */
 	protected $append = true;
 	
 	/**
-	 * @var string the file name used to append events
+	 * Path to the target file.
+	 * @var string 
 	 */
 	protected $file;
 
 	/**
-	 * @var mixed file resource
+	 * The file resource.
+	 * @var resource
 	 */
-	protected $fp = false;
+	protected $fp;
 	
-	public function activateOptions() {
-		$fileName = $this->getFile();
+	/** 
+	 * Helper function which can be easily overriden by daily file appender. 
+	 */
+	protected function getTargetFile() {
+		return $this->file;
+	}
+	
+	/**
+	 * Acquires the target file resource, creates the destination folder if 
+	 * necessary. Writes layout header to file.
+	 * 
+	 * @return boolean FALSE if opening failed
+	 */
+	protected function openFile() {
+		$file = $this->getTargetFile();
+
+		// Create the target folder if needed
+		if(!is_file($file)) {
+			$dir = dirname($file);
 
-		if (empty($fileName)) {
-			$this->warn("Required parameter 'fileName' not set. Closing appender.");
+			if(!is_dir($dir)) {
+				$success = mkdir($dir, 0777, true);
+				if ($success === false) {
+					$this->warn("Failed creating target directory [$dir]. Closing appender.");
+					$this->closed = true;
+					return false;
+				}
+			}
+		}
+		
+		$mode = $this->append ? 'a' : 'w';
+		$this->fp = fopen($file, $mode);
+		if ($this->fp === false) {
+			$this->warn("Failed opening target file. Closing appender.");
+			$this->fp = null;
 			$this->closed = true;
-			return;
+			return false;
 		}
 		
-		if(!is_file($fileName)) {
-			$dir = dirname($fileName);
-			if(!is_dir($dir)) {
-				mkdir($dir, 0777, true);
+		// Required when appending with concurrent access
+		if($this->append) {
+			fseek($this->fp, 0, SEEK_END);
+		}
+		
+		// Write the header
+		$this->write($this->layout->getHeader());
+	}
+	
+	/**
+	 * Writes a string to the target file. Opens file if not already open.
+	 * @param string $string Data to write.
+	 */
+	protected function write($string) {
+		// Lazy file open
+		if(!isset($this->fp)) {
+			if ($this->openFile() === false) {
+				return; // Do not write if file open failed.
 			}
 		}
-
-		$this->fp = fopen($fileName, ($this->getAppend()? 'a':'w'));
-		if($this->fp) {
-			if(flock($this->fp, LOCK_EX)) {
-				if($this->getAppend()) {
-					fseek($this->fp, 0, SEEK_END);
-				}
-				fwrite($this->fp, $this->layout->getHeader());
-				flock($this->fp, LOCK_UN);
-				$this->closed = false;
-			} else {
-				// TODO: should we take some action in this case?
-				$this->closed = true;
-			}		 
+		
+		if ($this->locking) {
+			$this->writeWithLocking($string);
 		} else {
-			$this->closed = true;
+			$this->writeWithoutLocking($string);
 		}
 	}
 	
-	public function close() {
-		if($this->closed != true) {
-			if($this->fp and $this->layout !== null) {
-				if(flock($this->fp, LOCK_EX)) {
-					fwrite($this->fp, $this->layout->getFooter());
-					flock($this->fp, LOCK_UN);
-				}
-				fclose($this->fp);
+	protected function writeWithLocking($string) {
+		if(flock($this->fp, LOCK_EX)) {
+			if(fwrite($this->fp, $string) === false) {
+				$this->warn("Failed writing to file. Closing appender.");
+				$this->closed = true;				
 			}
+			flock($this->fp, LOCK_UN);
+		} else {
+			$this->warn("Failed locking file for writing. Closing appender.");
+			$this->closed = true;
+		}
+	}
+	
+	protected function writeWithoutLocking($string) {
+		if(fwrite($this->fp, $string) === false) {
+			$this->warn("Failed writing to file. Closing appender.");
+			$this->closed = true;				
+		}
+	}
+	
+	public function activateOptions() {
+		if (empty($this->file)) {
+			$this->warn("Required parameter 'file' not set. Closing appender.");
 			$this->closed = true;
+			return;
 		}
 	}
+	
+	public function close() {
+		if (is_resource($this->fp)) {
+			$this->write($this->layout->getFooter());
+			fclose($this->fp);
+		}
+		$this->fp = null;
+		$this->closed = true;
+	}
 
 	public function append(LoggerLoggingEvent $event) {
-		if($this->fp and $this->layout !== null) {
-			if(flock($this->fp, LOCK_EX)) {
-				fwrite($this->fp, $this->layout->format($event));
-				flock($this->fp, LOCK_UN);
-			} else {
-				$this->closed = true;
-			}
-		} 
+		$this->write($this->layout->format($event));
 	}
 	
 	/**
-	 * Sets the file where the log output will go.
+	 * Sets the 'file' parameter.
 	 * @param string $file
 	 */
 	public function setFile($file) {
@@ -124,6 +182,7 @@ class LoggerAppenderFile extends LoggerAppender {
 	}
 	
 	/**
+	 * Returns the 'file' parameter.
 	 * @return string
 	 */
 	public function getFile() {
@@ -131,18 +190,23 @@ class LoggerAppenderFile extends LoggerAppender {
 	}
 	
 	/**
+	 * Returns the 'append' parameter.
 	 * @return boolean
 	 */
 	public function getAppend() {
 		return $this->append;
 	}
 
+	/**
+	 * Sets the 'append' parameter.
+	 * @param boolean $append
+	 */
 	public function setAppend($append) {
 		$this->setBoolean('append', $append);
 	}
 
 	/**
-	 * Sets the file where the log output will go.
+	 * Sets the 'file' parmeter. Left for legacy reasons.
 	 * @param string $fileName
 	 * @deprecated Use setFile() instead.
 	 */
@@ -151,12 +215,11 @@ class LoggerAppenderFile extends LoggerAppender {
 	}
 	
 	/**
+	 * Returns the 'file' parmeter. Left for legacy reasons.
 	 * @return string
 	 * @deprecated Use getFile() instead.
 	 */
 	public function getFileName() {
 		return $this->getFile();
 	}
-	
-	 
 }
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderFirePHP.php b/libraries/log4php.debug/appenders/LoggerAppenderFirePHP.php
new file mode 100644
index 0000000000000000000000000000000000000000..4601b910d9eda635ee9349a62d16e044e2eb9a33
--- /dev/null
+++ b/libraries/log4php.debug/appenders/LoggerAppenderFirePHP.php
@@ -0,0 +1,100 @@
+<?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.
+ */
+
+/**
+ * Logs messages as HTTP headers using the FirePHP Insight API.
+ * 
+ * This appender requires the FirePHP server library version 1.0 or later.
+ * 
+ * ## Configurable parameters: ##
+ * 
+ * - **target** - (string) The target to which messages will be sent. Possible options are 
+ *            'page' (default), 'request', 'package' and 'controller'. For more details,
+ *            see FirePHP documentation.
+ * 
+ * This class was originally contributed by Bruce Ingalls (Bruce.Ingalls-at-gmail-dot-com).
+ * 
+ * @link https://github.com/firephp/firephp FirePHP homepage.
+ * @link http://sourcemint.com/github.com/firephp/firephp/1:1.0.0b1rc6/-docs/Welcome FirePHP documentation.
+ * @link http://sourcemint.com/github.com/firephp/firephp/1:1.0.0b1rc6/-docs/Configuration/Constants FirePHP constants documentation.
+ * @link http://logging.apache.org/log4php/docs/appenders/firephp.html Appender documentation
+ * 
+ * @version $Revision: 1343684 $
+ * @package log4php
+ * @subpackage appenders
+ * @since 2.3
+ */
+class LoggerAppenderFirePHP extends LoggerAppender {
+	
+	/**
+	 * Instance of the Insight console class.
+	 * @var Insight_Plugin_Console
+	 */
+	protected $console;
+	
+	/**
+	 * The target for log messages. Possible values are: 'page' (default), 
+	 * 'request', 'package' and 'contoller'.
+	 */
+	protected $target = 'page';
+
+	public function activateOptions() {
+		if (method_exists('FirePHP', 'to')) {
+			$this->console = FirePHP::to($this->target)->console();
+			$this->closed = false;
+		} else {
+			$this->warn('FirePHP is not installed correctly. Closing appender.');
+		}
+	}
+	
+	public function append(LoggerLoggingEvent $event) {
+		$msg = $event->getMessage();
+		
+		// Skip formatting for objects and arrays which are handled by FirePHP.
+		if (!is_array($msg) && !is_object($msg)) {
+			$msg = $this->getLayout()->format($event);
+		}
+		
+		switch ($event->getLevel()->toInt()) {
+			case LoggerLevel::TRACE:
+			case LoggerLevel::DEBUG:
+				$this->console->log($msg);
+				break;
+			case LoggerLevel::INFO:
+				$this->console->info($msg);
+				break;
+			case LoggerLevel::WARN:
+				$this->console->warn($msg);
+				break;
+			case LoggerLevel::ERROR:
+			case LoggerLevel::FATAL:
+				$this->console->error($msg);
+				break;
+		}
+	}
+	
+	/** Returns the target. */
+	public function getTarget() {
+		return $this->target;
+	}
+
+	/** Sets the target. */
+	public function setTarget($target) {
+		$this->setString('target', $target);
+	}
+}
\ No newline at end of file
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderMail.php b/libraries/log4php.debug/appenders/LoggerAppenderMail.php
index a98d514832e896e374b184a7c3f447ee48798ae0..6204bcb2b905132c4c6573dd889ac88d18f0e1ca 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderMail.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderMail.php
@@ -14,61 +14,71 @@
  * 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
  */
 
 /**
- * Appends log events to mail using php function {@link PHP_MANUAL#mail}.
- *
- * The appender sends all log events at once after the request has been
- * finsished and the appender is beeing closed.
+ * LoggerAppenderMail appends log events via email.
  *
- * Configurable parameters for this appender:
+ * This appender does not send individual emails for each logging requests but 
+ * will collect them in a buffer and send them all in a single email once the 
+ * appender is closed (i.e. when the script exists). Because of this, it may 
+ * not appropriate for long running scripts, in which case 
+ * LoggerAppenderMailEvent might be a better choice.
  * 
- * - layout             - Sets the layout class for this appender (required)
- * - to                 - Sets the recipient of the mail (required)
- * - from               - Sets the sender of the mail (optional)
- * - subject            - Sets the subject of the mail (optional)
+ * This appender uses a layout.
  * 
- * An example:
+ * ## Configurable parameters: ##
  * 
- * {@example ../../examples/php/appender_mail.php 19}
+ * - **to** - Email address(es) to which the log will be sent. Multiple email 
+ *     addresses may be specified by separating them with a comma.
+ * - **from** - Email address which will be used in the From field.
+ * - **subject** - Subject of the email message.
  * 
- * {@example ../../examples/resources/appender_mail.properties 18}
- * 
- * The above will output something like:
- * <pre>
- *      Date: Tue,  8 Sep 2009 21:51:04 +0200 (CEST)
- *      From: someone@example.com
- *      To: root@localhost
- *      Subject: Log4php test
- *      
- *      Tue Sep  8 21:51:04 2009,120 [5485] FATAL root - Some critical message!
- *      Tue Sep  8 21:51:06 2009,120 [5485] FATAL root - Some more critical message!
- * </pre>
-
- * @version $Revision: 1213283 $
+ * @version $Revision: 1337820 $
  * @package log4php
  * @subpackage appenders
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/mail.html Appender documentation
  */
 class LoggerAppenderMail extends LoggerAppender {
 
-	/** @var string 'from' field */
+	/** 
+	 * Email address to put in From field of the email.
+	 * @var string
+	 */
 	protected $from = null;
 
-	/** @var string 'subject' field */
+	/** 
+	 * The subject of the email.
+	 * @var string
+	 */
 	protected $subject = 'Log4php Report';
 	
-	/** @var string 'to' field */
+	/**
+	 * One or more comma separated email addresses to which to send the email. 
+	 * @var string
+	 */
 	protected $to = null;
 
-	/** @var indiciates if this appender should run in dry mode */
+	/** 
+	 * Indiciates whether this appender should run in dry mode.
+	 * @deprecated
+	 * @var boolean 
+	 */
 	protected $dry = false;
 
-	/** @var string used to create mail body */
+	/** 
+	 * Buffer which holds the email contents before it is sent. 
+	 * @var string  
+	 */
 	protected $body = '';
 	
+	public function append(LoggerLoggingEvent $event) {
+		if($this->layout !== null) {
+			$this->body .= $this->layout->format($event);
+		}
+	}
+	
 	public function close() {
 		if($this->closed != true) {
 			$from = $this->from;
@@ -89,25 +99,38 @@ class LoggerAppenderMail extends LoggerAppender {
 		}
 	}
 	
+	/** Sets the 'subject' parameter. */
 	public function setSubject($subject) {
 		$this->setString('subject', $subject);
 	}
 	
+	/** Returns the 'subject' parameter. */
+	public function getSubject() {
+		return $this->subject;
+	}
+	
+	/** Sets the 'to' parameter. */
 	public function setTo($to) {
 		$this->setString('to', $to);
 	}
+	
+	/** Returns the 'to' parameter. */
+	public function getTo() {
+		return $this->to;
+	}
 
+	/** Sets the 'from' parameter. */
 	public function setFrom($from) {
 		$this->setString('from', $from);
 	}
+	
+	/** Returns the 'from' parameter. */
+	public function getFrom() {
+		return $this->from;
+	}
 
+	/** Enables or disables dry mode. */
 	public function setDry($dry) {
 		$this->setBoolean('dry', $dry);
 	}
-	
-	public function append(LoggerLoggingEvent $event) {
-		if($this->layout !== null) {
-			$this->body .= $this->layout->format($event);
-		}
-	}
 }
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderMailEvent.php b/libraries/log4php.debug/appenders/LoggerAppenderMailEvent.php
index 199de1a4bcf8dea2bacd2f146832504e0a30cf38..5e2350d733542aafa0394258b79e402dfe079ee4 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderMailEvent.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderMailEvent.php
@@ -14,71 +14,69 @@
  * 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
  */
 
 /**
- * Log every events as a separate email.
+ * LoggerAppenderMailEvent appends individual log events via email.
  * 
- * Configurable parameters for this appender are:
+ * This appender is similar to LoggerAppenderMail, except that it sends each 
+ * each log event in an individual email message at the time when it occurs.
  * 
- * - layout             - Sets the layout class for this appender (required)
- * - to                 - Sets the recipient of the mail (required)
- * - from               - Sets the sender of the mail (optional)
- * - subject            - Sets the subject of the mail (optional)
- * - smtpHost           - Sets the mail server (optional, default is ini_get('SMTP'))
- * - port               - Sets the port of the mail server (optional, default is 25)
- *
- * An example:
+ * This appender uses a layout.
  * 
- * {@example ../../examples/php/appender_mailevent.php 19}
- *  
- * {@example ../../examples/resources/appender_mailevent.properties 18}
- *
+ * ## Configurable parameters: ##
  * 
- * The above will output something like:
- * <pre>
- *      Date: Tue,  8 Sep 2009 21:51:04 +0200 (CEST)
- *      From: someone@example.com
- *      To: root@localhost
- *      Subject: Log4php test
- *
- *      Tue Sep  8 21:51:04 2009,120 [5485] FATAL root - Some critical message!
- * </pre>
+ * - **to** - Email address(es) to which the log will be sent. Multiple email
+ *     addresses may be specified by separating them with a comma.
+ * - **from** - Email address which will be used in the From field.
+ * - **subject** - Subject of the email message.
+ * - **smtpHost** - Used to override the SMTP server. Only works on Windows.
+ * - **port** - Used to override the default SMTP server port. Only works on 
+ *     Windows.
  *
- * @version $Revision: 1237433 $
+ * @version $Revision: 1343601 $
  * @package log4php
  * @subpackage appenders
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/mail-event.html Appender documentation
  */
 class LoggerAppenderMailEvent extends LoggerAppender {
 
-	/**  'from' field (defaults to 'sendmail_from' from php.ini on win32).
+	/** 
+	 * Email address to put in From field of the email.
 	 * @var string
 	 */
 	protected $from;
 
-	/** Mailserver port (win32 only).
+	/** 
+	 * Mail server port (widnows only).
 	 * @var integer 
 	 */
 	protected $port = 25;
 
-	/** Mailserver hostname (win32 only).
+	/** 
+	 * Mail server hostname (windows only).
 	 * @var string   
 	 */
-	protected $smtpHost = null;
+	protected $smtpHost;
 
-	/**
-	 * @var string 'subject' field
+	/** 
+	 * The subject of the email.
+	 * @var string
 	 */
-	protected $subject = '';
+	protected $subject = 'Log4php Report';
 
 	/**
-	 * @var string 'to' field
+	 * One or more comma separated email addresses to which to send the email. 
+	 * @var string
 	 */
 	protected $to = null;
 	
-	/** @var indiciates if this appender should run in dry mode */
+	/** 
+	 * Indiciates whether this appender should run in dry mode.
+	 * @deprecated
+	 * @var boolean 
+	 */
 	protected $dry = false;
 	
 	public function activateOptions() {
@@ -97,55 +95,86 @@ class LoggerAppenderMailEvent extends LoggerAppender {
 		
 		$this->closed = false;
 	}
+
+	public function append(LoggerLoggingEvent $event) {
+		$smtpHost = $this->smtpHost;
+		$prevSmtpHost = ini_get('SMTP');
+		if(!empty($smtpHost)) {
+			ini_set('SMTP', $smtpHost);
+		}
+	
+		$smtpPort = $this->port;
+		$prevSmtpPort= ini_get('smtp_port');
+		if($smtpPort > 0 and $smtpPort < 65535) {
+			ini_set('smtp_port', $smtpPort);
+		}
+	
+		// On unix only sendmail_path, which is PHP_INI_SYSTEM i.e. not changeable here, is used.
+	
+		$addHeader = empty($this->from) ? '' : "From: {$this->from}\r\n";
+	
+		if(!$this->dry) {
+			$result = mail($this->to, $this->subject, $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), $addHeader);
+		} else {
+			echo "DRY MODE OF MAIL APP.: Send mail to: ".$this->to." with additional headers '".trim($addHeader)."' and content: ".$this->layout->format($event);
+		}
+			
+		ini_set('SMTP', $prevSmtpHost);
+		ini_set('smtp_port', $prevSmtpPort);
+	}
 	
+	/** Sets the 'from' parameter. */
 	public function setFrom($from) {
 		$this->setString('from', $from);
 	}
 	
+	/** Returns the 'from' parameter. */
+	public function getFrom() {
+		return $this->from;
+	}
+	
+	/** Sets the 'port' parameter. */
 	public function setPort($port) {
 		$this->setPositiveInteger('port', $port);
 	}
 	
+	/** Returns the 'port' parameter. */
+	public function getPort() {
+		return $this->port;
+	}
+	
+	/** Sets the 'smtpHost' parameter. */
 	public function setSmtpHost($smtpHost) {
 		$this->setString('smtpHost', $smtpHost);
 	}
 	
+	/** Returns the 'smtpHost' parameter. */
+	public function getSmtpHost() {
+		return $this->smtpHost;
+	}
+	
+	/** Sets the 'subject' parameter. */
 	public function setSubject($subject) {
 		$this->setString('subject',  $subject);
 	}
 	
+	/** Returns the 'subject' parameter. */
+	public function getSubject() {
+		return $this->subject;
+	}
+	
+	/** Sets the 'to' parameter. */
 	public function setTo($to) {
 		$this->setString('to',  $to);
 	}
+	
+	/** Returns the 'to' parameter. */
+	public function getTo() {
+		return $this->to;
+	}
 
+	/** Enables or disables dry mode. */
 	public function setDry($dry) {
 		$this->setBoolean('dry', $dry);
 	}
-	
-	public function append(LoggerLoggingEvent $event) {
-		$smtpHost = $this->smtpHost;
-		$prevSmtpHost = ini_get('SMTP');
-		if(!empty($smtpHost)) {
-			ini_set('SMTP', $smtpHost);
-		} 
-
-		$smtpPort = $this->port;
-		$prevSmtpPort= ini_get('smtp_port');		
-		if($smtpPort > 0 and $smtpPort < 65535) {
-			ini_set('smtp_port', $smtpPort);
-		}
-
-		// On unix only sendmail_path, which is PHP_INI_SYSTEM i.e. not changeable here, is used.
-
-		$addHeader = empty($this->from) ? '' : "From: {$this->from}\r\n";
-		
-		if(!$this->dry) {
-			$result = mail($this->to, $this->subject, $this->layout->getHeader() . $this->layout->format($event) . $this->layout->getFooter($event), $addHeader);			
-		} else {
-			echo "DRY MODE OF MAIL APP.: Send mail to: ".$this->to." with additional headers '".trim($addHeader)."' and content: ".$this->layout->format($event);
-		}
-			
-		ini_set('SMTP', $prevSmtpHost);
-		ini_set('smtp_port', $prevSmtpPort);
-	}
 }
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderMongoDB.php b/libraries/log4php.debug/appenders/LoggerAppenderMongoDB.php
index e9e5117e8f74ed083880f432e8a93b922ee3b0ae..5caa49b42be2590e48a657d86b3c1a15545c0d82 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderMongoDB.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderMongoDB.php
@@ -14,8 +14,6 @@
  * 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
  */
  
 /**
@@ -23,13 +21,24 @@
  * 
  * This class was originally contributed by Vladimir Gorej.
  * 
- * @link http://github.com/log4mongo/log4mongo-php Vladimir Gorej's original submission.
- * @link http://www.mongodb.org/ MongoDB website.
+ * ## Configurable parameters: ##
+ * 
+ * - **host** - Server on which mongodb instance is located. 
+ * - **port** - Port on which the instance is bound.
+ * - **databaseName** - Name of the database to which to log.
+ * - **collectionName** - Name of the target collection within the given database.
+ * - **username** - Username used to connect to the database.
+ * - **password** - Password used to connect to the database.
+ * - **timeout** - For how long the driver should try to connect to the database (in milliseconds).
  * 
- * @version $Revision: 806678 $
+ * @version $Revision: 1346363 $
  * @package log4php
  * @subpackage appenders
  * @since 2.1
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/mongodb.html Appender documentation
+ * @link http://github.com/log4mongo/log4mongo-php Vladimir Gorej's original submission.
+ * @link http://www.mongodb.org/ MongoDB website.
  */
 class LoggerAppenderMongoDB extends LoggerAppender {
 	
@@ -96,15 +105,6 @@ class LoggerAppenderMongoDB extends LoggerAppender {
 	 */
 	protected $collection;
 
-	/** 
-	 * Set to true if the appender can append. 
-	 * @todo Maybe we should use $closed here instead? 
-	 */
-	protected $canAppend = false;
-	
-	/** Appender does not require a layout. */
-	protected $requiresLayout = false;
-		
 	public function __construct($name = '') {
 		parent::__construct($name);
 		$this->host = self::DEFAULT_MONGO_URL_PREFIX . self::DEFAULT_MONGO_HOST;
@@ -112,18 +112,17 @@ class LoggerAppenderMongoDB extends LoggerAppender {
 		$this->databaseName = self::DEFAULT_DB_NAME;
 		$this->collectionName = self::DEFAULT_COLLECTION_NAME;
 		$this->timeout = self::DEFAULT_TIMEOUT_VALUE;
+		$this->requiresLayout = false;
 	}
 	
 	/**
 	 * Setup db connection.
 	 * Based on defined options, this method connects to the database and 
 	 * creates a {@link $collection}. 
-	 *  
-	 * @throws Exception if the attempt to connect to the requested database fails.
 	 */
 	public function activateOptions() {
 		try {
-			$this->connection = new Mongo(sprintf('%s:%d', $this->host, $this->port), array("timeout" => $this->timeout));
+			$this->connection = new Mongo(sprintf('%s:%d', $this->host, $this->port), array('timeout' => $this->timeout));
 			$db	= $this->connection->selectDB($this->databaseName);
 			if ($this->userName !== null && $this->password !== null) {
 				$authResult = $db->authenticate($this->userName, $this->password);
@@ -131,25 +130,31 @@ class LoggerAppenderMongoDB extends LoggerAppender {
 					throw new Exception($authResult['errmsg'], $authResult['ok']);
 				}
 			}
-			
-			$this->collection = $db->selectCollection($this->collectionName);												 
+			$this->collection = $db->selectCollection($this->collectionName);
+		} catch (MongoConnectionException $ex) {
+			$this->closed = true;
+			$this->warn(sprintf('Failed to connect to mongo deamon: %s', $ex->getMessage()));
+		} catch (InvalidArgumentException $ex) {
+			$this->closed = true;
+			$this->warn(sprintf('Error while selecting mongo database: %s', $ex->getMessage()));
 		} catch (Exception $ex) {
-			$this->canAppend = false;
-			throw new LoggerException($ex);
-		} 
-			
-		$this->canAppend = true;
-	}		 
-	
+			$this->closed = true;
+			$this->warn('Invalid credentials for mongo database authentication');
+		}
+	}
+
 	/**
 	 * Appends a new event to the mongo database.
-	 * 
-	 * @throws LoggerException If the pattern conversion or the INSERT statement fails.
+	 *
+	 * @param LoggerLoggingEvent $event
 	 */
 	public function append(LoggerLoggingEvent $event) {
-		if ($this->canAppend == true && $this->collection != null) {
-			$document = $this->format($event);
-			$this->collection->insert($document);			
+		try {
+			if ($this->collection != null) {
+				$this->collection->insert($this->format($event));
+			}
+		} catch (MongoCursorException $ex) {
+			$this->warn(sprintf('Error while writing to mongo collection: %s', $ex->getMessage()));
 		}
 	}
 	
@@ -160,23 +165,23 @@ class LoggerAppenderMongoDB extends LoggerAppender {
 	 * @return array The array representation of the logging event.
 	 */
 	protected function format(LoggerLoggingEvent $event) {
-		$timestampSec  = (int) $event->getTimestamp();
+		$timestampSec = (int) $event->getTimestamp();
 		$timestampUsec = (int) (($event->getTimestamp() - $timestampSec) * 1000000);
 
 		$document = array(
-			'timestamp'  => new MongoDate($timestampSec, $timestampUsec),
-			'level'      => $event->getLevel()->toString(),
-			'thread'     => (int) $event->getThreadName(),
-			'message'    => $event->getMessage(),
+			'timestamp' => new MongoDate($timestampSec, $timestampUsec),
+			'level' => $event->getLevel()->toString(),
+			'thread' => (int) $event->getThreadName(),
+			'message' => $event->getMessage(),
 			'loggerName' => $event->getLoggerName() 
 		);	
 
 		$locationInfo = $event->getLocationInformation();
 		if ($locationInfo != null) {
-			$document['fileName']   = $locationInfo->getFileName();
-			$document['method']     = $locationInfo->getMethodName();
+			$document['fileName'] = $locationInfo->getFileName();
+			$document['method'] = $locationInfo->getMethodName();
 			$document['lineNumber'] = ($locationInfo->getLineNumber() == 'NA') ? 'NA' : (int) $locationInfo->getLineNumber();
-			$document['className']  = $locationInfo->getClassName();
+			$document['className'] = $locationInfo->getClassName();
 		}	
 
 		$throwableInfo = $event->getThrowableInformation();
@@ -197,15 +202,15 @@ class LoggerAppenderMongoDB extends LoggerAppender {
 	 */
 	protected function formatThrowable(Exception $ex) {
 		$array = array(				
-			'message'    => $ex->getMessage(),
-			'code'       => $ex->getCode(),
+			'message' => $ex->getMessage(),
+			'code' => $ex->getCode(),
 			'stackTrace' => $ex->getTraceAsString(),
 		);
-                        
+        
 		if (method_exists($ex, 'getPrevious') && $ex->getPrevious() !== null) {
 			$array['innerException'] = $this->formatThrowable($ex->getPrevious());
 		}
-			
+		
 		return $array;
 	}
 		
@@ -217,13 +222,16 @@ class LoggerAppenderMongoDB extends LoggerAppender {
 			$this->collection = null;
 			if ($this->connection !== null) {
 				$this->connection->close();
-				$this->connection = null;	
-			}					
+				$this->connection = null;
+			}
 			$this->closed = true;
 		}
 	}
 	
-	/** Sets the value of {@link $host} parameter. */
+	/** 
+	 * Sets the value of {@link $host} parameter.
+	 * @param string $host
+	 */
 	public function setHost($host) {
 		if (!preg_match('/^mongodb\:\/\//', $host)) {
 			$host = self::DEFAULT_MONGO_URL_PREFIX . $host;
@@ -231,67 +239,106 @@ class LoggerAppenderMongoDB extends LoggerAppender {
 		$this->host = $host;
 	}
 		
-	/** Returns the value of {@link $host} parameter. */
+	/** 
+	 * Returns the value of {@link $host} parameter.
+	 * @return string
+	 */
 	public function getHost() {
 		return $this->host;
 	}
-		
-	/** Sets the value of {@link $port} parameter. */
+
+	/** 
+	 * Sets the value of {@link $port} parameter.
+	 * @param int $port
+	 */
 	public function setPort($port) {
 		$this->setPositiveInteger('port', $port);
 	}
 		
-	/** Returns the value of {@link $port} parameter. */
+	/** 
+	 * Returns the value of {@link $port} parameter.
+	 * @return int
+	 */
 	public function getPort() {
 		return $this->port;
 	}
-		
-	/** Sets the value of {@link $databaseName} parameter. */
+
+	/** 
+	 * Sets the value of {@link $databaseName} parameter.
+	 * @param string $databaseName
+	 */
 	public function setDatabaseName($databaseName) {
 		$this->setString('databaseName', $databaseName);
 	}
 		
-	/** Returns the value of {@link $databaseName} parameter. */
+	/** 
+	 * Returns the value of {@link $databaseName} parameter.
+	 * @return string
+	 */
 	public function getDatabaseName() {
 		return $this->databaseName;
 	}
-	
-	/** Sets the value of {@link $collectionName} parameter. */
+
+	/** 
+	 * Sets the value of {@link $collectionName} parameter.
+	 * @param string $collectionName
+	 */
 	public function setCollectionName($collectionName) {
 		$this->setString('collectionName', $collectionName);
 	}
 		
-	/** Returns the value of {@link $collectionName} parameter. */
+	/** 
+	 * Returns the value of {@link $collectionName} parameter.
+	 * @return string
+	 */
 	public function getCollectionName() {
 		return $this->collectionName;
 	}
-		
-	/** Sets the value of {@link $userName} parameter. */
+
+	/** 
+	 * Sets the value of {@link $userName} parameter.
+	 * @param string $userName
+	 */
 	public function setUserName($userName) {
 		$this->setString('userName', $userName, true);
 	}
 	
-	/** Returns the value of {@link $userName} parameter. */
+	/** 
+	 * Returns the value of {@link $userName} parameter.
+	 * @return string
+	 */
 	public function getUserName() {
 		return $this->userName;
 	}
-		
-	/** Sets the value of {@link $password} parameter. */
+
+	/** 
+	 * Sets the value of {@link $password} parameter.
+	 * @param string $password
+	 */
 	public function setPassword($password) {
 		$this->setString('password', $password, true);
 	}
 		
-	/** Returns the value of {@link $password} parameter. */
+	/** 
+	 * Returns the value of {@link $password} parameter.
+	 * @return string 
+	 */
 	public function getPassword() {
 		return $this->password;
 	}
-	
-	/** Sets the value of {@link $timeout} parameter. */
+
+	/** 
+	 * Sets the value of {@link $timeout} parameter.
+	 * @param int $timeout
+	 */
 	public function setTimeout($timeout) {
 		$this->setPositiveInteger('timeout', $timeout);
 	}
 
-	/** Returns the value of {@link $timeout} parameter. */
+	/** 
+	 * Returns the value of {@link $timeout} parameter.
+	 * @return int
+	 */
 	public function getTimeout() {
 		return $this->timeout;
 	}
@@ -311,4 +358,3 @@ class LoggerAppenderMongoDB extends LoggerAppender {
 		return $this->collection;
 	}
 }
-?>
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderNull.php b/libraries/log4php.debug/appenders/LoggerAppenderNull.php
index 0de2a949ac40c2ad2324cc2b609e69d413dd6043..e4b1b5601fa15a1095b4646db005897cc422744f 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderNull.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderNull.php
@@ -14,8 +14,6 @@
  * 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
  */
 
 /**
@@ -23,15 +21,11 @@
  *
  * This appender has no configurable parameters.
  * 
- * An example:
- * 
- * {@example ../../examples/php/appender_null.php 19}
- * 
- * {@example ../../examples/resources/appender_null.properties 18}
- * 
- * @version $Revision: 1166182 $
+ * @version $Revision: 1343601 $
  * @package log4php
  * @subpackage appenders
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/null.html Appender documentation
  */
 class LoggerAppenderNull extends LoggerAppender {
 
@@ -48,4 +42,3 @@ class LoggerAppenderNull extends LoggerAppender {
 	public function append(LoggerLoggingEvent $event) {
 	}
 }
-
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderPDO.php b/libraries/log4php.debug/appenders/LoggerAppenderPDO.php
index 8bd27b8f8f1d4c19f67f8f6e65432c935993d080..966db998965c34e84227c3a3be9f2512d24d0208 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderPDO.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderPDO.php
@@ -14,297 +14,269 @@
  * 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
  */
 
 /**
- * Appends log events to a db table using PDO.
+ * LoggerAppenderPDO appender logs to a database using the PHP's PDO extension.
  *
- * Configurable parameters of this appender are:
+ * ## Configurable parameters: ##
  *
- * - user            - Sets the user of this database connection
- * - password        - Sets the password of this database connection
- * - createTable     - true, if the table should be created if necessary. false otherwise
- * - table           - Sets the table name (default: log4php_log)
- * - sql             - Sets the insert statement for a logging event. Defaults
+ * - dsn             - The Data Source Name (DSN) used to connect to the database.
+ * - user            - Username used to connect to the database.
+ * - password        - Password used to connect to the database.
+ * - table           - Name of the table to which log entries are be inserted.
+ * - insertSQL       - Sets the insert statement for a logging event. Defaults
  *                     to the correct one - change only if you are sure what you are doing.
- * - dsn             - Sets the DSN string for this connection
- *
- * If $sql is set then $table and $sql are used, else $table, $insertSql and $insertPattern.
+ * - insertPattern   - The conversion pattern to use in conjuction with insert 
+ *                     SQL. Must contain the same number of comma separated 
+ *                     conversion patterns as there are question marks in the 
+ *                     insertSQL.
  *
- * An example:
- *
- * {@example ../../examples/php/appender_pdo.php 19}
- * 
- * {@example ../../examples/resources/appender_pdo.properties 18}
- * 
- * @version $Revision: 806678 $
+ * @version $Revision: 1374546 $
  * @package log4php
  * @subpackage appenders
  * @since 2.0
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/pdo.html Appender documentation
  */
 class LoggerAppenderPDO extends LoggerAppender {
 
-	/** 
-	 * Create the log table if it does not exists (optional).
-	 * @var string 
-	 */
-	protected $createTable = true;
+	// ******************************************
+	// *** Configurable parameters            ***
+	// ******************************************
 	
 	/** 
-	 * Database user name.
-	 * @var string 
+	 * DSN string used to connect to the database.
+	 * @see http://www.php.net/manual/en/pdo.construct.php
 	 */
+	protected $dsn;
+
+	/** Database user name. */
 	protected $user;
 	
-	/** 
-	 * Database password
-	 * @var string 
-	 */
+	/** Database password. */
 	protected $password;
 	
 	/** 
-	 * DSN string for enabling a connection.
-	 * @var string 
-	 */
-	protected $dsn;
-	
-	/** 
-	 * A {@link LoggerPatternLayout} string used to format a valid insert query.
-	 * @deprecated Use {@link $insertSql} and {@link $insertPattern} which properly handle quotes in the messages!
-	 * @var string 
-	 */
-	protected $sql;
-	
-	/** 
-	 * Can be set to a complete insert statement with ? that are replaced using {@link insertPattern}.
-	 * @var string 
+	 * The insert query.
+	 * 
+	 * The __TABLE__ placeholder will be replaced by the table name from 
+	 * {@link $table}.
+	 *  
+	 * The questionmarks are part of the prepared statement, and they must 
+	 * match the number of conversion specifiers in {@link insertPattern}.
 	 */
-	protected $insertSql = "INSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?,?,?,?,?,?,?)";
+	protected $insertSQL = "INSERT INTO __TABLE__ (timestamp, logger, level, message, thread, file, line) VALUES (?, ?, ?, ?, ?, ?, ?)";
 
 	/** 
-	 * A comma separated list of {@link LoggerPatternLayout} format strings that replace the "?" in {@link $sql}.
-	 * @var string 
+	 * A comma separated list of {@link LoggerPatternLayout} format strings 
+	 * which replace the "?" in {@link $insertSQL}.
+	 * 
+	 * Must contain the same number of comma separated conversion patterns as 
+	 * there are question marks in {@link insertSQL}.
+ 	 * 
+ 	 * @see LoggerPatternLayout For conversion patterns.
 	 */
-	protected $insertPattern = "%d,%c,%p,%m,%t,%F,%L";
+	protected $insertPattern = "%date{Y-m-d H:i:s},%logger,%level,%message,%pid,%file,%line";
 
-	/** 
-	 * Table name to write events. Used only for CREATE TABLE if {@link $createTable} is true.
-	 * @var string 
-	 */
+	/** Name of the table to which to append log events. */
 	protected $table = 'log4php_log';
 	
+	/** The number of recconect attempts to make on failed append. */
+	protected $reconnectAttempts = 3;
+	
+	
+	// ******************************************
+	// *** Private memebers                   ***
+	// ******************************************
+	
 	/** 
 	 * The PDO instance.
 	 * @var PDO 
 	 */
-	protected $db = null;
+	protected $db;
 	
 	/** 
-	 * Prepared statement for the INSERT INTO query.
+	 * Prepared statement for the insert query.
 	 * @var PDOStatement 
 	 */
 	protected $preparedInsert;
-
-	/** 
-	 * Set in activateOptions() and later used in append() to check if all conditions to append are true.
-	 * @var boolean 
-	 */
-	protected $canAppend = true;
 	
-	/**
-	 * This appender does not require a layout.
-	 */
+	/** This appender does not require a layout. */
 	protected $requiresLayout = false;
+
+
+	// ******************************************
+	// *** Appender methods                   ***
+	// ******************************************
 	
 	/**
-	 * Setup db connection.
-	 * Based on defined options, this method connects to db defined in {@link $dsn}
-	 * and creates a {@link $table} table if {@link $createTable} is true.
-	 * @return boolean true if all ok.
-	 * @throws a PDOException if the attempt to connect to the requested database fails.
+	 * Acquires a database connection based on parameters.
+	 * Parses the insert pattern to create a chain of converters which will be
+	 * used in forming query parameters from logging events.
 	 */
 	public function activateOptions() {
 		try {
-			if($this->user === null) {
-				$this->db = new PDO($this->dsn);
-			} else if($this->password === null) {
-				$this->db = new PDO($this->dsn, $this->user);
-			} else {
-				$this->db = new PDO($this->dsn,$this->user,$this->password);
-			}
-			$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-			
-			// test if log table exists
-			try {
-				$result = $this->db->query('SELECT * FROM ' . $this->table . ' WHERE 1 = 0');
-				$result->closeCursor(); 
-			} catch (PDOException $e) {
-				// It could be something else but a "no such table" is the most likely
-				$result = false;
-			}
-			
-			// create table if necessary
-			if ($result == false and $this->createTable) {
-				// The syntax should at least be compatible with MySQL, PostgreSQL, SQLite and Oracle.
-				$query = "CREATE TABLE {$this->table} (".
-							"timestamp varchar(32)," .
-							"logger varchar(64)," .
-							"level varchar(32)," .
-							"message varchar(9999)," .
-							"thread varchar(32)," .
-							"file varchar(255)," .
-							"line varchar(6))";
-				$result = $this->db->query($query);
-			}
+			$this->establishConnection();
 		} catch (PDOException $e) {
-			$this->canAppend = false;
-			throw new LoggerException($e);
+			$this->warn("Failed connecting to database. Closing appender. Error: " . $e->getMessage());
+			$this->close();
+			return;
+		}
+
+		// Parse the insert patterns; pattern parts are comma delimited
+		$pieces = explode(',', $this->insertPattern);
+		$converterMap = LoggerLayoutPattern::getDefaultConverterMap();
+		foreach($pieces as $pattern) {
+			$parser = new LoggerPatternParser($pattern, $converterMap);
+			$this->converters[] = $parser->parse(); 
 		}
 		
-		$this->layout = new LoggerLayoutPattern();
+		$this->closed = false;
+	}
+	
+	/** 
+	 * Connects to the database, and prepares the insert query.
+	 * @throws PDOException If connect or prepare fails.  
+	 */
+	protected function establishConnection() {
+		// Acquire database connection
+		$this->db = new PDO($this->dsn, $this->user, $this->password);
+		$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 		
-		//
-		// Keep compatibility to legacy option $sql which already included the format patterns!
-		//
-		if (empty($this->sql)) {
-			// new style with prepared Statment and $insertSql and $insertPattern
-			// Maybe the tablename has to be substituted.
-			$this->insertSql = preg_replace('/__TABLE__/', $this->table, $this->insertSql);
-			$this->preparedInsert = $this->db->prepare($this->insertSql);
-			$this->layout->setConversionPattern($this->insertPattern);
-		} else {
-			// Old style with format strings in the $sql query should be used.
-		$this->layout->setConversionPattern($this->sql);
-		}
-
-		$this->canAppend = true;
-		return true;
+		// Prepare the insert statement
+		$insertSQL = str_replace('__TABLE__', $this->table, $this->insertSQL);
+		$this->preparedInsert = $this->db->prepare($insertSQL);
 	}
 	
 	/**
 	 * Appends a new event to the database.
 	 * 
-	 * @throws LoggerException If the pattern conversion or the INSERT statement fails.
+	 * If writing to database fails, it will retry by re-establishing the 
+	 * connection up to $reconnectAttempts times. If writing still fails, 
+	 * the appender will close.
 	 */
 	public function append(LoggerLoggingEvent $event) {
-		// TODO: Can't activateOptions() simply throw an Exception if it encounters problems?
-		if ( ! $this->canAppend) return;
 
+		for ($attempt = 1; $attempt <= $this->reconnectAttempts + 1; $attempt++) {
 			try {
-			if (empty($this->sql)) {
-				// new style with prepared statement
-				$params = $this->layout->formatToArray($event);
-				$this->preparedInsert->execute($params);
-			} else {
-				// old style
-				$query = $this->layout->format($event);
-				$this->db->exec($query);
+				// Attempt to write to database
+				$this->preparedInsert->execute($this->format($event));
+				$this->preparedInsert->closeCursor();
+				break;
+			} catch (PDOException $e) {
+				$this->warn("Failed writing to database: ". $e->getMessage());
+				
+				// Close the appender if it's the last attempt
+				if ($attempt > $this->reconnectAttempts) {
+					$this->warn("Failed writing to database after {$this->reconnectAttempts} reconnect attempts. Closing appender.");
+					$this->close();
+				// Otherwise reconnect and try to write again
+				} else {
+					$this->warn("Attempting a reconnect (attempt $attempt of {$this->reconnectAttempts}).");
+					$this->establishConnection();
+				}
 			}
-			} catch (Exception $e) {
-				throw new LoggerException($e);
+		}
+	}
+	
+	/**
+	 * Converts the logging event to a series of database parameters by using 
+	 * the converter chain which was set up on activation. 
+	 */
+	protected function format(LoggerLoggingEvent $event) {
+		$params = array();
+		foreach($this->converters as $converter) {
+			$buffer = '';
+			while ($converter !== null) {
+				$converter->format($buffer, $event);
+				$converter = $converter->next;
 			}
+			$params[] = $buffer;
 		}
+		return $params;
+	}
 	
 	/**
 	 * Closes the connection to the logging database
 	 */
 	public function close() {
-		if($this->closed != true) {
-			if ($this->db !== null) {
-				$this->db = null;
-			}
-			$this->closed = true;
-		}
+		// Close the connection (if any)
+		$this->db = null;
+		
+		// Close the appender
+		$this->closed = true;
 	}
 	
+	// ******************************************
+	// *** Accessor methods                   ***
+	// ******************************************
+	
 	/**
-	 * Sets the username for this connection. 
-	 * Defaults to ''
+	 * Returns the active database handle or null if not established.
+	 * @return PDO
 	 */
+	public function getDatabaseHandle() {
+		return $this->db;
+	}
+	
+	/** Sets the username. */
 	public function setUser($user) {
 		$this->setString('user', $user);
 	}
 	
-	/**
-	 * Sets the password for this connection. 
-	 * Defaults to ''
-	 */
+	/** Returns the username. */
+	public function getUser($user) {
+		return $this->user;
+	}
+	
+	/** Sets the password. */
 	public function setPassword($password) {
 		$this->setString('password', $password);
 	}
 	
-	/**
-	 * Indicator if the logging table should be created on startup,
-	 * if its not existing.
-	 */
-	public function setCreateTable($flag) {
-		$this->setBoolean('createTable', $flag);
+	/** Returns the password. */
+	public function getPassword($password) {
+		return $this->password;
 	}
-   
-   	/**
-	 * Sets the SQL string into which the event should be transformed.
-	 * Defaults to:
-	 * 
-	 * INSERT INTO $this->table 
-	 * ( timestamp, logger, level, message, thread, file, line) 
-	 * VALUES 
-	 * ('%d','%c','%p','%m','%t','%F','%L')
-	 * 
-	 * It's not necessary to change this except you have customized logging'
-	 *
-	 * @deprecated See {@link setInsertSql} and {@link setInsertPattern}.
-	 */
-	public function setSql($sql) {
-		$this->setString('sql', $sql);
+	
+	/** Sets the insert SQL. */
+	public function setInsertSQL($sql) {
+		$this->setString('insertSQL', $sql);
 	}
 	
-	/**
-	 * Sets the SQL INSERT string to use with {@link $insertPattern}.
-	 *
-	 * @param $sql		  A complete INSERT INTO query with "?" that gets replaced.
-	 */
-	public function setInsertSql($sql) {
-		$this->setString('insertSql', $sql);
+	/** Returns the insert SQL. */
+	public function getInsertSQL($sql) {
+		return $this->insertSQL;
 	}
 
-	/**
-	 * Sets the {@link LoggerLayoutPattern} format strings for {@link $insertSql}.
-	 *
-	 * It's not necessary to change this except you have customized logging.
-	 *
-	 * @param $pattern		  Comma separated format strings like "%p,%m,%C"
-	 */
+	/** Sets the insert pattern. */
 	public function setInsertPattern($pattern) {
 		$this->setString('insertPattern', $pattern);
 	}
+	
+	/** Returns the insert pattern. */
+	public function getInsertPattern($pattern) {
+		return $this->insertPattern;
+	}
 
-	/**
-	 * Sets the tablename to which this appender should log.
-	 * Defaults to log4php_log
-	 */
+	/** Sets the table name. */
 	public function setTable($table) {
 		$this->setString('table', $table);
 	}
 	
-	/**
-	 * Sets the DSN string for this connection. In case of
-	 * SQLite it could look like this: 'sqlite:appenders/pdotest.sqlite'
-	 */
+	/** Returns the table name. */
+	public function getTable($table) {
+		return $this->table;
+	}
+	
+	/** Sets the DSN string. */
 	public function setDSN($dsn) {
 		$this->setString('dsn', $dsn);
 	}
 	
-	/**
-	 * Sometimes databases allow only one connection to themselves in one thread.
-	 * SQLite has this behaviour. In that case this handle is needed if the database
-	 * must be checked for events.
-	 *
-	 * @return PDO
-	 */
-	public function getDatabaseHandle() {
-		return $this->db;
-	}
+	/** Returns the DSN string. */
+	public function getDSN($dsn) {
+		return $this->setString('dsn', $dsn);
+	}	
 }
-
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderPhp.php b/libraries/log4php.debug/appenders/LoggerAppenderPhp.php
index 9840d8000a786e0bc5fc3a1707a666bebc67e8ba..f1d8ceff9402c28a5438ca8f9dd85b6d75b390f9 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderPhp.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderPhp.php
@@ -14,12 +14,11 @@
  * 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
  */
 
 /**
- * Log events using php {@link PHP_MANUAL#trigger_error} function and a {@link LoggerLayoutTTCC} default layout.
+ * LoggerAppenderPhp logs events by creating a PHP user-level message using 
+ * the PHP's trigger_error()function.
  *
  * This appender has no configurable parameters.
  *
@@ -29,28 +28,22 @@
  * - <b>WARN <= level < ERROR</b> mapped to E_USER_WARNING
  * - <b>level >= ERROR</b> mapped to E_USER_ERROR  
  *
- * An example:
- * 
- * {@example ../../examples/php/appender_php.php 19}
- * 
- * {@example ../../examples/resources/appender_php.properties 18}
- *
- * @version $Revision: 1166182 $
+ * @version $Revision: 1337820 $
  * @package log4php
  * @subpackage appenders
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/php.html Appender documentation
  */ 
 class LoggerAppenderPhp extends LoggerAppender {
 
 	public function append(LoggerLoggingEvent $event) {
-		if($this->layout !== null) {
-			$level = $event->getLevel();
-			if($level->isGreaterOrEqual(LoggerLevel::getLevelError())) {
-				trigger_error($this->layout->format($event), E_USER_ERROR);
-			} else if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) {
-				trigger_error($this->layout->format($event), E_USER_WARNING);
-			} else {
-				trigger_error($this->layout->format($event), E_USER_NOTICE);
-			}
+		$level = $event->getLevel();
+		if($level->isGreaterOrEqual(LoggerLevel::getLevelError())) {
+			trigger_error($this->layout->format($event), E_USER_ERROR);
+		} else if ($level->isGreaterOrEqual(LoggerLevel::getLevelWarn())) {
+			trigger_error($this->layout->format($event), E_USER_WARNING);
+		} else {
+			trigger_error($this->layout->format($event), E_USER_NOTICE);
 		}
 	}
 }
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderRollingFile.php b/libraries/log4php.debug/appenders/LoggerAppenderRollingFile.php
index a00eacd8b9a95446bae24b7c3ff3d53be8a4c3f9..dbd69de68d68b6508c62b6319bd0c46b190ba93b 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderRollingFile.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderRollingFile.php
@@ -19,48 +19,40 @@
  */
 
 /**
- * LoggerAppenderRollingFile extends LoggerAppenderFile to backup the log files 
- * when they reach a certain size.
+ * LoggerAppenderRollingFile writes logging events to a specified file. The 
+ * file is rolled over after a specified size has been reached.
  * 
  * This appender uses a layout.
  *
- * Parameters are:
- * - file              - The target file to write to
- * - filename          - The target file to write to (deprecated, use "file" instead).
- * - append            - Sets if the appender should append to the end of the file or overwrite content ("true" or "false")
- * - maxBackupIndex    - Set the maximum number of backup files to keep around (int)
- * - maxFileSize       - Set the maximum size that the output file is allowed to
- *                       reach before being rolled over to backup files.
- *                       Suffixes like "KB", "MB" or "GB" are allowed, f. e. "10KB" is interpreted as 10240
- * - maximumFileSize   - Alias to maxFileSize (deprecated, use "maxFileSize" instead)
- *
- * <p>Contributors: Sergio Strampelli.</p>
- *
- * An example:
- *
- * {@example ../../examples/php/appender_socket.php 19}
- *
- * {@example ../../examples/resources/appender_socket.properties 18}
+ * ## Configurable parameters: ##
+ * 
+ * - **file** - Path to the target file.
+ * - **append** - If set to true, the appender will append to the file, 
+ *     otherwise the file contents will be overwritten.
+ * - **maxBackupIndex** - Maximum number of backup files to keep. Default is 1.
+ * - **maxFileSize** - Maximum allowed file size (in bytes) before rolling 
+ *     over. Suffixes "KB", "MB" and "GB" are allowed. 10KB = 10240 bytes, etc.
+ *     Default is 10M.
+ * - **compress** - If set to true, rolled-over files will be compressed. 
+ *     Requires the zlib extension.
  *
- * @version $Revision: 1213283 $
+ * @version $Revision: 1394975 $
  * @package log4php
  * @subpackage appenders
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/rolling-file.html Appender documentation
  */
 class LoggerAppenderRollingFile extends LoggerAppenderFile {
 
+	/** Compressing backup files is done in chunks, this determines how large. */
+	const COMPRESS_CHUNK_SIZE = 102400; // 100KB
+	
 	/**
-	 * Set the maximum size that the output file is allowed to reach
+	 * The maximum size (in bytes) that the output file is allowed to reach 
 	 * before being rolled over to backup files.
 	 *
-	 * <p>In configuration files, the <var>MaxFileSize</var> option takes a
-	 * long integer in the range 0 - 2^63. You can specify the value
-	 * with the suffixes "KB", "MB" or "GB" so that the integer is
-	 * interpreted being expressed respectively in kilobytes, megabytes
-	 * or gigabytes. For example, the value "10KB" will be interpreted
-	 * as 10240.</p>
-	 * <p>The default maximum file size is 10MB.</p>
-	 *
-	 * <p>Note that MaxFileSize cannot exceed <b>2 GB</b>.</p>
+	 * The default maximum file size is 10MB (10485760 bytes). Maximum value 
+	 * for this option may depend on the file system.
 	 *
 	 * @var integer
 	 */
@@ -69,30 +61,32 @@ class LoggerAppenderRollingFile extends LoggerAppenderFile {
 	/**
 	 * Set the maximum number of backup files to keep around.
 	 * 
-	 * <p>The <var>MaxBackupIndex</var> option determines how many backup
-	 * files are kept before the oldest is erased. This option takes
-	 * a positive integer value. If set to zero, then there will be no
-	 * backup files and the log file will be truncated when it reaches
-	 * MaxFileSize.</p>
-	 * <p>There is one backup file by default.</p>
+	 * Determines how many backup files are kept before the oldest is erased. 
+	 * This option takes a positive integer value. If set to zero, then there 
+	 * will be no backup files and the log file will be truncated when it 
+	 * reaches <var>maxFileSize</var>.
+	 * 
+	 * There is one backup file by default.
 	 *
 	 * @var integer 
 	 */
 	protected $maxBackupIndex = 1;
 	
 	/**
-	 * @var string the filename expanded
+	 * The <var>compress</var> parameter determindes the compression with zlib. 
+	 * If set to true, the rollover files are compressed and saved with the .gz extension.
+	 * @var boolean
 	 */
-	private $expandedFileName = null;
+	protected $compress = false;
 
 	/**
-	 * Returns the value of the MaxBackupIndex option.
-	 * @return integer 
+	 * Set to true in the constructor if PHP >= 5.3.0. In that case clearstatcache
+	 * supports conditional clearing of statistics.
+	 * @var boolean
+	 * @see http://php.net/manual/en/function.clearstatcache.php
 	 */
-	private function getExpandedFileName() {
-		return $this->expandedFileName;
-	}
-
+	private $clearConditional = false;
+	
 	/**
 	 * Get the maximum size that the output file is allowed to reach
 	 * before being rolled over to backup files.
@@ -102,37 +96,40 @@ class LoggerAppenderRollingFile extends LoggerAppenderFile {
 		return $this->maxFileSize;
 	}
 
+	public function __construct($name = '') {
+		parent::__construct($name);
+		if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
+			$this->clearConditional = true;
+		}
+	}
+	
 	/**
 	 * Implements the usual roll over behaviour.
 	 *
-	 * <p>If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. 
+	 * If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. 
 	 * Moreover, File is renamed File.1 and closed. A new File is created to receive further log output.
 	 * 
-	 * <p>If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created.
+	 * If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created.
 	 * 
 	 * Rollover must be called while the file is locked so that it is safe for concurrent access. 
+	 * 
+	 * @throws LoggerException If any part of the rollover procedure fails.
 	 */
 	private function rollOver() {
 		// If maxBackups <= 0, then there is no file renaming to be done.
 		if($this->maxBackupIndex > 0) {
-			$fileName = $this->getExpandedFileName();
-
 			// Delete the oldest file, to keep Windows happy.
-			$file = $fileName . '.' . $this->maxBackupIndex;
-			if(is_writable($file))
-				unlink($file);
+			$file = $this->file . '.' . $this->maxBackupIndex;
+			
+			if (file_exists($file) && !unlink($file)) {
+				throw new LoggerException("Unable to delete oldest backup file from [$file].");
+			}
 
 			// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
-			for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) {
-				$file = $fileName . "." . $i;
-				if(is_readable($file)) {
-					$target = $fileName . '.' . ($i + 1);
-					rename($file, $target);
-				}
-			}
+			$this->renameArchievedLogs($this->file);
 	
 			// Backup the active file
-			copy($fileName, "$fileName.1");
+			$this->moveToBackup($this->file);
 		}
 		
 		// Truncate the active file
@@ -140,92 +137,169 @@ class LoggerAppenderRollingFile extends LoggerAppenderFile {
 		rewind($this->fp);
 	}
 	
-	public function setFile($fileName) {
-		$this->file = $fileName;
-		// As LoggerAppenderFile does not create the directory, it has to exist.
-		// realpath() fails if the argument does not exist so the filename is separated.
-		$this->expandedFileName = realpath(dirname($fileName));
-		if ($this->expandedFileName === false) throw new Exception("Directory of $fileName does not exist!");
-		$this->expandedFileName .= DIRECTORY_SEPARATOR . basename($fileName);
+	private function moveToBackup($source) {
+		if ($this->compress) {
+			$target = $source . '.1.gz';
+			$this->compressFile($source, $target);
+		} else {
+			$target = $source . '.1';
+			copy($source, $target);
+		}
 	}
-
-
-	/**
-	 * Set the maximum number of backup files to keep around.
-	 * 
-	 * <p>The <b>MaxBackupIndex</b> option determines how many backup
-	 * files are kept before the oldest is erased. This option takes
-	 * a positive integer value. If set to zero, then there will be no
-	 * backup files and the log file will be truncated when it reaches
-	 * MaxFileSize.
-	 *
-	 * @param mixed $maxBackups
-	 */
-	public function setMaxBackupIndex($maxBackups) {
-		$this->setPositiveInteger('maxBackupIndex', $maxBackups);
+	
+	private function compressFile($source, $target) {
+		$target = 'compress.zlib://' . $target;
+		
+		$fin = fopen($source, 'rb');
+		if ($fin === false) {
+			throw new LoggerException("Unable to open file for reading: [$source].");
+		}
+		
+		$fout = fopen($target, 'wb');
+		if ($fout === false) {
+			throw new LoggerException("Unable to open file for writing: [$target].");
+		}
+	
+		while (!feof($fin)) {
+			$chunk = fread($fin, self::COMPRESS_CHUNK_SIZE);
+			if (false === fwrite($fout, $chunk)) {
+				throw new LoggerException("Failed writing to compressed file.");
+			}
+		}
+	
+		fclose($fin);
+		fclose($fout);
 	}
-
-	/**
-	 * Set the maximum size that the output file is allowed to reach
-	 * before being rolled over to backup files.
-	 *
-	 * @param mixed $maxFileSize
-	 * @see setMaxFileSize()
-	 * @deprecated
-	 */
-	public function setMaximumFileSize($maxFileSize) {
-		return $this->setMaxFileSize($maxFileSize);
+	
+	private function renameArchievedLogs($fileName) {
+		for($i = $this->maxBackupIndex - 1; $i >= 1; $i--) {
+			
+			$source = $fileName . "." . $i;
+			if ($this->compress) {
+				$source .= '.gz';
+			}
+			
+			if(file_exists($source)) {
+				$target = $fileName . '.' . ($i + 1);
+				if ($this->compress) {
+					$target .= '.gz';
+				}				
+				
+				rename($source, $target);
+			}
+		}
 	}
-
+	
 	/**
-	 * Set the maximum size that the output file is allowed to reach
-	 * before being rolled over to backup files.
-	 * <p>In configuration files, the <b>maxFileSize</b> option takes an
-	 * long integer in the range 0 - 2^63. You can specify the value
-	 * with the suffixes "KB", "MB" or "GB" so that the integer is
-	 * interpreted being expressed respectively in kilobytes, megabytes
-	 * or gigabytes. For example, the value "10KB" will be interpreted
-	 * as 10240.
-	 *
-	 * @param mixed $value
-	 * @return the actual file size set
+	 * Writes a string to the target file. Opens file if not already open.
+	 * @param string $string Data to write.
 	 */
-	public function setMaxFileSize($value) {
-		$this->setFileSize('maxFileSize', $value);
-	}
-
-	public function append(LoggerLoggingEvent $event) {
-		if($this->fp and $this->layout !== null) {
-			if(flock($this->fp, LOCK_EX)) {
-				fwrite($this->fp, $this->layout->format($event));
-
-				// Stats cache must be cleared, otherwise filesize() returns cached results
+	protected function write($string) {
+		// Lazy file open
+		if(!isset($this->fp)) {
+			if ($this->openFile() === false) {
+				return; // Do not write if file open failed.
+			}
+		}
+		
+		// Lock the file while writing and possible rolling over
+		if(flock($this->fp, LOCK_EX)) {
+			
+			// Write to locked file
+			if(fwrite($this->fp, $string) === false) {
+				$this->warn("Failed writing to file. Closing appender.");
+				$this->closed = true;
+			}
+			
+			// Stats cache must be cleared, otherwise filesize() returns cached results
+			// If supported (PHP 5.3+), clear only the state cache for the target file
+			if ($this->clearConditional) {
+				clearstatcache(true, $this->file);
+			} else {
 				clearstatcache();
-				
-				// Rollover if needed
-				if (filesize($this->expandedFileName) > $this->maxFileSize) {
+			}
+			
+			// Rollover if needed
+			if (filesize($this->file) > $this->maxFileSize) {
+				try {
 					$this->rollOver();
+				} catch (LoggerException $ex) {
+					$this->warn("Rollover failed: " . $ex->getMessage() . " Closing appender.");
+					$this->closed = true;
 				}
-				
-				flock($this->fp, LOCK_UN);
-			} else {
-				$this->closed = true;
 			}
-		} 
+			
+			flock($this->fp, LOCK_UN);
+		} else {
+			$this->warn("Failed locking file for writing. Closing appender.");
+			$this->closed = true;
+		}
+	}
+	
+	public function activateOptions() {
+		parent::activateOptions();
+		
+		if ($this->compress && !extension_loaded('zlib')) {
+			$this->warn("The 'zlib' extension is required for file compression. Disabling compression.");
+			$this->compression = false;
+		}
 	}
 	
 	/**
-	 * @return Returns the maximum number of backup files to keep around.
+	 * Set the 'maxBackupIndex' parameter.
+	 * @param integer $maxBackupIndex
+	 */
+	public function setMaxBackupIndex($maxBackupIndex) {
+		$this->setPositiveInteger('maxBackupIndex', $maxBackupIndex);
+	}
+	
+	/**
+	 * Returns the 'maxBackupIndex' parameter.
+	 * @return integer
 	 */
 	public function getMaxBackupIndex() {
 		return $this->maxBackupIndex;
 	}
 	
 	/**
-	 * @return Returns the maximum size that the output file is allowed to reach
-	 * before being rolled over to backup files.
+	 * Set the 'maxFileSize' parameter.
+	 * @param mixed $maxFileSize
+	 */
+	public function setMaxFileSize($maxFileSize) {
+		$this->setFileSize('maxFileSize', $maxFileSize);
+	}
+	
+	/**
+	 * Returns the 'maxFileSize' parameter.
+	 * @return integer
 	 */
 	public function getMaxFileSize() {
 		return $this->maxFileSize;
 	}
+	
+	/**
+	 * Set the 'maxFileSize' parameter (kept for backward compatibility).
+	 * @param mixed $maxFileSize
+	 * @deprecated Use setMaxFileSize() instead.
+	 */
+	public function setMaximumFileSize($maxFileSize) {
+		$this->warn("The 'maximumFileSize' parameter is deprecated. Use 'maxFileSize' instead.");
+		return $this->setMaxFileSize($maxFileSize);
+	}
+	
+	/**
+	 * Sets the 'compress' parameter.
+	 * @param boolean $compress
+	 */
+	public function setCompress($compress) {
+		$this->setBoolean('compress', $compress);
+	}
+	
+	/**
+	 * Returns the 'compress' parameter.
+	 * @param boolean 
+	 */
+	public function getCompress() {
+		return $this->compress;
+	}
 }
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderSocket.php b/libraries/log4php.debug/appenders/LoggerAppenderSocket.php
index 3fc3623713ba4b20f16a27c86d071d5ea93e3b21..f6c2a6059244f9b630d1f54766c473a5219401fa 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderSocket.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderSocket.php
@@ -14,25 +14,25 @@
  * 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
  */
 
 /**
- * Appends events to a network socket.
+ * LoggerAppenderSocket appends to a network socket.
  *
- * This appender can be configured by changing the following attributes:
+ * ## Configurable parameters: ##
  * 
- * - remoteHost - Target remote host.
- * - port       - Target port (optional, defaults to 4446).
- * - timeout    - Connection timeout in seconds (optional, defaults to
- *                'default_socket_timeout' from php.ini)
+ * - **remoteHost** - Target remote host.
+ * - **port** - Target port (optional, defaults to 4446).
+ * - **timeout** - Connection timeout in seconds (optional, defaults to 
+ *     'default_socket_timeout' from php.ini)
  * 
  * The socket will by default be opened in blocking mode.
  * 
- * @version $Revision: 1213283 $
+ * @version $Revision: 1337820 $
  * @package log4php
  * @subpackage appenders
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/socket.html Appender documentation
  */ 
 class LoggerAppenderSocket extends LoggerAppender {
 	
diff --git a/libraries/log4php.debug/appenders/LoggerAppenderSyslog.php b/libraries/log4php.debug/appenders/LoggerAppenderSyslog.php
index 1ae57bb3a9345269e7e7188700c0238bcabe0809..2a7a26ef8c81e9da7842405de4287d7f9da39cc1 100644
--- a/libraries/log4php.debug/appenders/LoggerAppenderSyslog.php
+++ b/libraries/log4php.debug/appenders/LoggerAppenderSyslog.php
@@ -14,46 +14,48 @@
  * 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
  */
 
 /**
- * Log events to a system log using the {@link PHP_MANUAL#syslog} function.
+ * Log events to a system log using the PHP syslog() function.
  *
  * This appenders requires a layout.
  *
- * Configurable parameters:
+ * ## Configurable parameters: ##
  * 
- * - ident            - The ident of the syslog message.
- * - priority         - The priority for the syslog message (used when overriding priority).
- * - facility         - The facility for the syslog message
- * - overridePriority - If set to true, the message priority will always use 
- *                      the value defined in {@link $priority}, otherwise the
- *                      priority will be determined by the message's log level.  
- * - option           - The option value for the syslog message. 
+ * - **ident** - The ident of the syslog message.
+ * - **priority** - The priority for the syslog message (used when overriding 
+ *     priority).
+ * - **facility** - The facility for the syslog message
+ * - **overridePriority** - If set to true, the message priority will always 
+ *     use the value defined in {@link $priority}, otherwise the priority will
+ *     be determined by the message's log level.  
+ * - **option** - The option value for the syslog message. 
  *
  * Recognised syslog options are:
- * 	- CONS 	 - if there is an error while sending data to the system logger, write directly to the system console
- * 	- NDELAY - open the connection to the logger immediately
- * 	- ODELAY - delay opening the connection until the first message is logged (default)
- * 	- PERROR - print log message also to standard error
- * 	- PID    - include PID with each message
+ * 
+ * - CONS 	 - if there is an error while sending data to the system logger, write directly to the system console
+ * - NDELAY - open the connection to the logger immediately
+ * - ODELAY - delay opening the connection until the first message is logged (default)
+ * - PERROR - print log message also to standard error
+ * - PID    - include PID with each message
  * 
  * Multiple options can be set by delimiting them with a pipe character, 
  * e.g.: "CONS|PID|PERROR".
  * 
  * Recognised syslog priorities are:
- * 	- EMERG
- * 	- ALERT
- * 	- CRIT
- * 	- ERR
- * 	- WARNING
- * 	- NOTICE
- * 	- INFO
- * 	- DEBUG
+ * 
+ * - EMERG
+ * - ALERT
+ * - CRIT
+ * - ERR
+ * - WARNING
+ * - NOTICE
+ * - INFO
+ * - DEBUG
  *
  * Levels are mapped as follows:
+ * 
  * - <b>FATAL</b> to LOG_ALERT
  * - <b>ERROR</b> to LOG_ERR 
  * - <b>WARN</b> to LOG_WARNING
@@ -61,15 +63,11 @@
  * - <b>DEBUG</b> to LOG_DEBUG
  * - <b>TRACE</b> to LOG_DEBUG
  *
- * An example:
- *
- * {@example ../../examples/php/appender_syslog.php 19}
- *
- * {@example ../../examples/resources/appender_syslog.properties 18}
- *
- * @version $Revision: 1230527 $
+ * @version $Revision: 1337820 $
  * @package log4php
  * @subpackage appenders
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
+ * @link http://logging.apache.org/log4php/docs/appenders/syslog.html Appender documentation
  */ 
 class LoggerAppenderSyslog extends LoggerAppender {
 	
@@ -166,7 +164,7 @@ class LoggerAppenderSyslog extends LoggerAppender {
 	} 
 	
 	/**
-	* Sets the {@link $option}.
+	* Sets the 'option' parameter.
 	*
 	* @param string $option
 	*/
@@ -175,7 +173,7 @@ class LoggerAppenderSyslog extends LoggerAppender {
 	}
 	
 	/**
-	* Returns the {@link $ident}.
+	* Returns the 'ident' parameter.
 	*
 	* @return string $ident
 	*/
@@ -184,7 +182,7 @@ class LoggerAppenderSyslog extends LoggerAppender {
 	}
 	
 	/**
-	 * Returns the {@link $priority}.
+	 * Returns the 'priority' parameter.
 	 *
 	 * @return string
 	 */
@@ -193,7 +191,7 @@ class LoggerAppenderSyslog extends LoggerAppender {
 	}
 	
 	/**
-	 * Returns the {@link $facility}.
+	 * Returns the 'facility' parameter.
 	 *
 	 * @return string
 	 */
@@ -202,7 +200,7 @@ class LoggerAppenderSyslog extends LoggerAppender {
 	}
 	
 	/**
-	 * Returns the {@link $overridePriority}.
+	 * Returns the 'overridePriority' parameter.
 	 *
 	 * @return string
 	 */
@@ -211,7 +209,7 @@ class LoggerAppenderSyslog extends LoggerAppender {
 	}
 	
 	/**
-	 * Returns the {@link $option}.
+	 * Returns the 'option' parameter.
 	 *
 	 * @return string
 	 */
diff --git a/libraries/log4php.debug/configurators/LoggerConfigurationAdapter.php b/libraries/log4php.debug/configurators/LoggerConfigurationAdapter.php
index a9bd8fd9cc2f48db591dc4a6a07024b0b7f74575..a202eab768e9fa75483d00e9e5134405867cad24 100644
--- a/libraries/log4php.debug/configurators/LoggerConfigurationAdapter.php
+++ b/libraries/log4php.debug/configurators/LoggerConfigurationAdapter.php
@@ -27,7 +27,7 @@
  * @package log4php
  * @subpackage configurators
  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
+ * @version $Revision: 1343601 $
  * @since 2.2
  */
 interface LoggerConfigurationAdapter
@@ -37,4 +37,3 @@ interface LoggerConfigurationAdapter
 
 }
 
-?>
\ No newline at end of file
diff --git a/libraries/log4php.debug/configurators/LoggerConfigurationAdapterINI.php b/libraries/log4php.debug/configurators/LoggerConfigurationAdapterINI.php
index 801e52ab59dcc971fcded49d3d71c7b531dd32f0..91b6c8697055f821e7ff4528f2b184f521d20141 100644
--- a/libraries/log4php.debug/configurators/LoggerConfigurationAdapterINI.php
+++ b/libraries/log4php.debug/configurators/LoggerConfigurationAdapterINI.php
@@ -27,7 +27,7 @@
  * @package log4php
  * @subpackage configurators
  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
+ * @version $Revision: 1343601 $
  * @since 2.2
  */
 class LoggerConfigurationAdapterINI implements LoggerConfigurationAdapter {
@@ -59,12 +59,6 @@ class LoggerConfigurationAdapterINI implements LoggerConfigurationAdapter {
 	/**
 	 * Loads and parses the INI configuration file.
 	 * 
-	 * INI_SCANNER_RAW is used here because otherwise parse_ini_file() will 
-	 * try to parse all values, with some strange results. For example, "true"
-	 * will become "1", while "false" and "null" will become "" (empty string). 
-	 * 
-	 * @see http://php.net/manual/en/function.parse-ini-file.php
-	 * 
 	 * @param string $url Path to the config file.
 	 * @throws LoggerException
 	 */
@@ -303,4 +297,3 @@ class LoggerConfigurationAdapterINI implements LoggerConfigurationAdapter {
 	
 }
 
-?>
diff --git a/libraries/log4php.debug/configurators/LoggerConfigurationAdapterPHP.php b/libraries/log4php.debug/configurators/LoggerConfigurationAdapterPHP.php
index 91f5fc9340a63b2ee42c9d83f537ef9c5ed1ac4e..f7abfe700bf8edca195e0792632ac8c0021551aa 100644
--- a/libraries/log4php.debug/configurators/LoggerConfigurationAdapterPHP.php
+++ b/libraries/log4php.debug/configurators/LoggerConfigurationAdapterPHP.php
@@ -46,7 +46,7 @@
  * @package log4php
  * @subpackage configurators
  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
+ * @version $Revision: 1343601 $
  * @since 2.2
  */
 class LoggerConfigurationAdapterPHP implements LoggerConfigurationAdapter
@@ -82,4 +82,3 @@ class LoggerConfigurationAdapterPHP implements LoggerConfigurationAdapter
 	}
 }
 
-?>
\ No newline at end of file
diff --git a/libraries/log4php.debug/configurators/LoggerConfigurationAdapterXML.php b/libraries/log4php.debug/configurators/LoggerConfigurationAdapterXML.php
index 980692cac6c0f0e44f6eaf12b55b36767f32ab46..743150d790b8a3a3c54ad89cc05d989c75bf7380 100644
--- a/libraries/log4php.debug/configurators/LoggerConfigurationAdapterXML.php
+++ b/libraries/log4php.debug/configurators/LoggerConfigurationAdapterXML.php
@@ -24,7 +24,7 @@
  * @package log4php
  * @subpackage configurators
  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision$
+ * @version $Revision: 1394956 $
  * @since 2.2
  */
 class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
@@ -38,8 +38,7 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
 		'renderers' => array(),
 	);
 	
-	public function convert($url)
-	{
+	public function convert($url) {
 		$xml = $this->loadXML($url);
 		
 		$this->parseConfiguration($xml);
@@ -63,6 +62,12 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
 		foreach($xml->renderer as $rendererNode) {
 			$this->parseRenderer($rendererNode);
 		}
+
+		// Process <defaultRenderer> node
+		foreach($xml->defaultRenderer as $rendererNode) {
+			$this->parseDefaultRenderer($rendererNode);
+		}
+
 		return $this->config;
 	}
 	
@@ -146,7 +151,8 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
 		}
 		
 		return $layout;
-	}

+	}
+
 	/** Parses any <param> child nodes returning them in an array. */
 	private function parseParameters($paramsNode) {
 		$params = array();
@@ -174,10 +180,7 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
 			$logger['level'] = $this->getAttributeValue($node->level, 'value');
 		}
 		
-		$logger['appenders'] = array();
-		foreach($node->appender_ref as $appender) {
-			$logger['appenders'][] = $this->getAttributeValue($appender, 'ref');
-		}
+		$logger['appenders'] = $this->parseAppenderReferences($node);
 		
 		$this->config['rootLogger'] = $logger;
 	}
@@ -200,7 +203,7 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
 			$logger['additivity'] = $this->getAttributeValue($node, 'additivity');
 		}
 		
-		$logger['appenders'] = $this->parseAppenderReferences($node, $name);
+		$logger['appenders'] = $this->parseAppenderReferences($node);
 
 		// Check for duplicate loggers
 		if (isset($this->config['loggers'][$name])) {
@@ -212,13 +215,20 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
 	
 	/** 
 	 * Parses a <logger> node for appender references and returns them in an array.
+	 * 
+	 * Previous versions supported appender-ref, as well as appender_ref so both
+	 * are parsed for backward compatibility.
 	 */
-	private function parseAppenderReferences(SimpleXMLElement $node, $name) {
+	private function parseAppenderReferences(SimpleXMLElement $node) {
 		$refs = array();
 		foreach($node->appender_ref as $ref) {
 			$refs[] = $this->getAttributeValue($ref, 'ref');
 		}
 		
+		foreach($node->{'appender-ref'} as $ref) {
+			$refs[] = $this->getAttributeValue($ref, 'ref');
+		}
+
 		return $refs;
 	}
 	
@@ -242,6 +252,18 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
 		$this->config['renderers'][] = compact('renderedClass', 'renderingClass');
 	}
 	
+	/** Parses a <defaultRenderer> node. */
+	private function parseDefaultRenderer(SimpleXMLElement $node) {
+		$renderingClass = $this->getAttributeValue($node, 'renderingClass');
+		
+		// Warn on duplicates
+		if(isset($this->config['defaultRenderer'])) {
+			$this->warn("Duplicate <defaultRenderer> node. Overwriting.");
+		}
+		
+		$this->config['defaultRenderer'] = $renderingClass; 
+	}
+	
 	// ******************************************
 	// ** Helper methods                       **
 	// ******************************************
@@ -255,4 +277,3 @@ class LoggerConfigurationAdapterXML implements LoggerConfigurationAdapter
 	}
 }
 
-?>
\ No newline at end of file
diff --git a/libraries/log4php.debug/configurators/LoggerConfiguratorDefault.php b/libraries/log4php.debug/configurators/LoggerConfiguratorDefault.php
index 8ea21c8cf7be3e5217facf180e1153ff17edd834..08bccf915b235fabe9907e8a0923acebd5c73c94 100644
--- a/libraries/log4php.debug/configurators/LoggerConfiguratorDefault.php
+++ b/libraries/log4php.debug/configurators/LoggerConfiguratorDefault.php
@@ -25,7 +25,7 @@
  * 
  * @package log4php
  * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
- * @version $Revision: 1212319 $
+ * @version $Revision: 1394956 $
  * @since 2.2
  */
 class LoggerConfiguratorDefault implements LoggerConfigurator
@@ -55,10 +55,7 @@ class LoggerConfiguratorDefault implements LoggerConfigurator
         ),
         'appenders' => array(
             'default' => array(
-                'class' => 'LoggerAppenderEcho',
-                'layout' => array(
-                    'class' => 'LoggerLayoutTTCC',
-                ),
+                'class' => 'LoggerAppenderEcho'
             ),
         ),
 	);
@@ -100,8 +97,7 @@ class LoggerConfiguratorDefault implements LoggerConfigurator
 	 * 		will be used.
 	 * @return array The parsed configuration.
 	 */
-	public function parse($input)
-	{
+	public function parse($input) {
 		// No input - use default configuration
 		if (!isset($input)) {
 			$config = self::$defaultConfiguration;
@@ -224,38 +220,35 @@ class LoggerConfiguratorDefault implements LoggerConfigurator
 				$this->configureRenderer($hierarchy, $rendererConfig);
 			}
 		}
+		
+		if (isset($config['defaultRenderer'])) {
+			$this->configureDefaultRenderer($hierarchy, $config['defaultRenderer']);
+		}
 	}
 	
 	private function configureRenderer(LoggerHierarchy $hierarchy, $config) {
-		if (!isset($config['renderingClass'])) {
-			$this->warn("Rendering class not specified. Skipping renderers definition.");
-			return;			
+		if (empty($config['renderingClass'])) {
+			$this->warn("Rendering class not specified. Skipping renderer definition.");
+			return;
 		}
 		
-		$renderingClass = $config['renderingClass'];
-		if (!class_exists($renderingClass)) {
-			$this->warn("Nonexistant rendering class [$renderingClass] specified. Skipping renderers definition.");
+		if (empty($config['renderedClass'])) {
+			$this->warn("Rendered class not specified. Skipping renderer definition.");
 			return;
 		}
 		
-		$renderingClassInstance = new $renderingClass();
-		if (!$renderingClassInstance instanceof LoggerRendererObject) {
-			$this->warn("Invalid class [$renderingClass] given. Not a valid LoggerRenderer class. Skipping renderers definition.");
-			return;			
-		}
+		// Error handling performed by RendererMap
+		$hierarchy->getRendererMap()->addRenderer($config['renderedClass'], $config['renderingClass']);
+	}
 	
-		if (!isset($config['renderedClass'])) {
-			$this->warn("Rendered class not specified for rendering Class [$renderingClass]. Skipping renderers definition.");
-			return;			
+	private function configureDefaultRenderer(LoggerHierarchy $hierarchy, $class) {
+		if (empty($class)) {
+			$this->warn("Rendering class not specified. Skipping default renderer definition.");
+			return;
 		}
 		
-		$renderedClass = $config['renderedClass'];
-		if (!class_exists($renderedClass)) {
-			$this->warn("Nonexistant rendered class [$renderedClass] specified for renderer [$renderingClass]. Skipping renderers definition.");
-			return;
-		}		
-
-		$hierarchy->getRendererMap()->addRenderer($renderedClass, $renderingClassInstance);
+		// Error handling performed by RendererMap
+		$hierarchy->getRendererMap()->setDefaultRenderer($class);
 	}
 	
 	/** 
@@ -416,7 +409,6 @@ class LoggerConfiguratorDefault implements LoggerConfigurator
 			if (isset($level)) {
 				$logger->setLevel($level);
 			} else {
-				$default = $logger->getLevel();
 				$this->warn("Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.");
 			}
 		}
@@ -434,10 +426,10 @@ class LoggerConfiguratorDefault implements LoggerConfigurator
 		
 		// Set logger additivity
 		if (isset($config['additivity'])) {
-			$additivity = LoggerOptionConverter::toBoolean($config['additivity'], null);
-			if (is_bool($additivity)) {
+			try {
+				$additivity = LoggerOptionConverter::toBooleanEx($config['additivity'], null);
 				$logger->setAdditivity($additivity);
-			} else {
+			} catch (Exception $ex) {
 				$this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.");
 			}
 		}
@@ -482,4 +474,4 @@ class LoggerConfiguratorDefault implements LoggerConfigurator
 	private function warn($message) {
 		trigger_error("log4php: $message", E_USER_WARNING);
 	}
-}
\ No newline at end of file
+}
diff --git a/libraries/log4php.debug/helpers/LoggerBasicPatternConverter.php b/libraries/log4php.debug/helpers/LoggerBasicPatternConverter.php
deleted file mode 100644
index 18b8c9134652a221b4e421f599e5bfff914c3e1e..0000000000000000000000000000000000000000
--- a/libraries/log4php.debug/helpers/LoggerBasicPatternConverter.php
+++ /dev/null
@@ -1,71 +0,0 @@
-<?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
- */
-
-/**
- * @package log4php
- * @subpackage helpers
- */
-class LoggerBasicPatternConverter extends LoggerPatternConverter {
-
-	/**
-	 * @var integer
-	 */
-	private $type;
-
-	/**
-	 * Constructor
-	 *
-	 * @param string $formattingInfo
-	 * @param integer $type
-	 */
-	public function __construct($formattingInfo, $type) {
-		parent::__construct($formattingInfo);
-		$this->type = $type;
-	}
-
-	/**
-	 * @param LoggerLoggingEvent $event
-	 * @return string
-	 */
-	public function convert($event) {
-		switch($this->type) {
-			case LoggerPatternParser::RELATIVE_TIME_CONVERTER:
-				$timeStamp = $event->getTimeStamp();
-				$startTime = LoggerLoggingEvent::getStartTime();
-				return (string)(int)($timeStamp * 1000 - $startTime * 1000);
-				
-			case LoggerPatternParser::THREAD_CONVERTER:
-				return $event->getThreadName();
-
-			case LoggerPatternParser::LEVEL_CONVERTER:
-				$level = $event->getLevel();
-				return $level->toString();
-
-			case LoggerPatternParser::NDC_CONVERTER:
-				return $event->getNDC();
-
-			case LoggerPatternParser::MESSAGE_CONVERTER:
-				return $event->getRenderedMessage();
-				
-			default: 
-				return '';
-		}
-	}
-}
diff --git a/libraries/log4php.debug/helpers/LoggerFormattingInfo.php b/libraries/log4php.debug/helpers/LoggerFormattingInfo.php
index 9ebcc7e63aa50528ba264a3cfa45cedc6138389b..a8a54a611c005b8eaebc04c6016755e9b05b02cb 100644
--- a/libraries/log4php.debug/helpers/LoggerFormattingInfo.php
+++ b/libraries/log4php.debug/helpers/LoggerFormattingInfo.php
@@ -27,24 +27,28 @@
  * @since 0.3
  */
 class LoggerFormattingInfo {
-
-	public $min = -1;
-	public $max = 0x7FFFFFFF;
-	public $leftAlign = false;
-
+	
+	/** 
+	 * Minimal output length. If output is shorter than this value, it will be
+	 * padded with spaces. 
+	 */
+	public $min = 0;
+	
+	/** 
+	 * Maximum output length. If output is longer than this value, it will be 
+	 * trimmed.
+	 */
+	public $max = PHP_INT_MAX;
+	
 	/**
-	 * Constructor
+	 * Whether to pad the string from the left. If set to false, the string 
+	 * will be padded from the right. 
 	 */
-	public function __construct() {}
+	public $padLeft = true;
 	
-	public function reset() {
-		$this->min = -1;
-		$this->max = 0x7FFFFFFF;
-		$this->leftAlign = false;
-	}
-
-	public function dump() {
-		// TODO: other option to dump?
-		// LoggerLog::debug("LoggerFormattingInfo::dump() min={$this->min}, max={$this->max}, leftAlign={$this->leftAlign}");
-	}
+	/**
+	 * Whether to trim the string from the left. If set to false, the string
+	 * will be trimmed from the right.
+	 */
+	public $trimLeft = false;
 }
diff --git a/libraries/log4php.debug/helpers/LoggerLocationPatternConverter.php b/libraries/log4php.debug/helpers/LoggerLocationPatternConverter.php
deleted file mode 100644
index 5d78c923c3e0edd9ed999840ccbab10c982d9707..0000000000000000000000000000000000000000
--- a/libraries/log4php.debug/helpers/LoggerLocationPatternConverter.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?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
- */
-
-/**
- * @package log4php
- * @subpackage helpers
- */
-class LoggerLocationPatternConverter extends LoggerPatternConverter {
-	
-	/**
-	 * @var integer
-	 */
-	private $type;
-
-	/**
-	 * Constructor
-	 *
-	 * @param string $formattingInfo
-	 * @param integer $type
-	 */
-	public function __construct($formattingInfo, $type) {
-		parent::__construct($formattingInfo);
-		$this->type = $type;
-	}
-
-	/**
-	 * @param LoggerLoggingEvent $event
-	 * @return string
-	 */
-	public function convert($event) {
-		$locationInfo = $event->getLocationInformation();
-		switch($this->type) {
-			case LoggerPatternParser::FULL_LOCATION_CONVERTER:
-				return $locationInfo->getFullInfo();
-			case LoggerPatternParser::METHOD_LOCATION_CONVERTER:
-				return $locationInfo->getMethodName();
-			case LoggerPatternParser::LINE_LOCATION_CONVERTER:
-				return $locationInfo->getLineNumber();
-			case LoggerPatternParser::FILE_LOCATION_CONVERTER:
-				return $locationInfo->getFileName();
-			case LoggerPatternParser::CLASS_LOCATION_CONVERTER:
-				return $locationInfo->getFullQualifiedClassname();
-			default: 
-				return '';
-		}
-	}
-}
-
diff --git a/libraries/log4php.debug/helpers/LoggerNamedPatternConverter.php b/libraries/log4php.debug/helpers/LoggerNamedPatternConverter.php
deleted file mode 100644
index eda3326c85cf2e33e8455209c97a01408faaa3de..0000000000000000000000000000000000000000
--- a/libraries/log4php.debug/helpers/LoggerNamedPatternConverter.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?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
- */
-
-/**
- * @package log4php
- * @subpackage helpers
- */
-class LoggerNamedPatternConverter extends LoggerPatternConverter {
-
-	/**
-	 * @var integer
-	 */
-	private $precision;
-
-	/**
-	 * Constructor
-	 *
-	 * @param string $formattingInfo
-	 * @param integer $precision
-	 */
-	public function __construct($formattingInfo, $precision) {
-		parent::__construct($formattingInfo);
-		$this->precision = $precision;
-	}
-
-	/**
-	 * @param LoggerLoggingEvent $event
-	 * @return string
-	 */
-	public function getFullyQualifiedName($event) {
-		return;
-	}
-
-	/**
-	 * @param LoggerLoggingEvent $event
-	 * @return string
-	 */
-	function convert($event) {
-		$n = $this->getFullyQualifiedName($event);
-		if($this->precision <= 0) {
-			return $n;
-		} else {
-			
-			// TODO: do this with explode()
-			
-			$len = strlen($n);
-			// We substract 1 from 'len' when assigning to 'end' to avoid out of
-			// bounds exception in return r.substring(end+1, len). This can happen if
-			// precision is 1 and the category name ends with a dot.
-			$end = $len -1 ;
-			for($i = $this->precision; $i > 0; $i--) {
-				$end = strrpos(substr($n, 0, ($end - 1)), '.');
-				if($end == false) {
-					return $n;
-				}
-			}
-			return substr($n, ($end + 1), $len);
-		}
-	}
-}
diff --git a/libraries/log4php.debug/helpers/LoggerOptionConverter.php b/libraries/log4php.debug/helpers/LoggerOptionConverter.php
index c63dc9633b4e6f8eb17ff8408f72474e4904e61f..6b0a1ee3b0c76943855f632fb34403a5cdc28131 100644
--- a/libraries/log4php.debug/helpers/LoggerOptionConverter.php
+++ b/libraries/log4php.debug/helpers/LoggerOptionConverter.php
@@ -21,17 +21,12 @@
 /**
  * A convenience class to convert property values to specific types.
  *
- * @version $Revision: 1237446 $ 
+ * @version $Revision: 1374617 $ 
  * @package log4php
  * @subpackage helpers
  * @since 0.5
  */
 class LoggerOptionConverter {
-
-	const DELIM_START = '${';
-	const DELIM_STOP = '}';
-	const DELIM_START_LEN = 2;
-	const DELIM_STOP_LEN = 1;
 	
 	/** String values which are converted to boolean TRUE. */
 	private static $trueValues = array('1', 'true', 'yes', 'on');
@@ -70,37 +65,6 @@ class LoggerOptionConverter {
 		}
 	}
 
-	/**
-	 * If <var>$value</var> is <i>true</i>, then <i>true</i> is
-	 * returned. If <var>$value</var> is <i>false</i>, then
-	 * <i>true</i> is returned. Otherwise, <var>$default</var> is
-	 * returned.
-	 *
-	 * <p>Case of value is unimportant.</p>
-	 *
-	 * @param string $value
-	 * @param boolean $default
-	 * @return boolean
-	 */
-	public static function toBoolean($value, $default=true) {
-		if (is_null($value)) {
-			return $default;
-		} elseif (is_string($value)) {
-			$trimmedVal = strtolower(trim($value));
-			if("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) {
-				return true;
-			} else if ("" == $trimmedVal or "0" == $trimmedVal or "false" == $trimmedVal or "no" == $trimmedVal or "off" == $trimmedVal) {
-				return false;
-			}
-		} elseif (is_bool($value)) {
-			return $value;
-		} elseif (is_int($value)) {
-			return !($value == 0); // true is everything but 0 like in C 
-		}
-		
-		return $default;
-	}
-
 	/** Converts $value to boolean, or throws an exception if not possible. */
 	public static function toBooleanEx($value) {
 		if (isset($value)) {
@@ -119,21 +83,6 @@ class LoggerOptionConverter {
 		throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to boolean.");
 	}
 	
-	/**
-	 * @param string $value
-	 * @param integer $default
-	 * @return integer
-	 */
-	public static function toInt($value, $default) {
-		$value = trim($value);
-		if(is_numeric($value)) {
-			return (int)$value;
-		} else {
-			return $default;
-		}
-	}
-	
-	
 	/** 
 	 * Converts $value to integer, or throws an exception if not possible. 
 	 * Floats cannot be converted to integer.
@@ -164,68 +113,6 @@ class LoggerOptionConverter {
 		throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to a positive integer.");
 	}
 
-	/**
-	 * Converts a standard or custom priority level to a Level
-	 * object.
-	 *
-	 * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>",
-	 * where <i>full_file_classname</i> means the class filename with path
-	 * but without php extension, then the specified class' <i>toLevel()</i> method
-	 * is called to process the specified level string; if no '#'
-	 * character is present, then the default {@link LoggerLevel}
-	 * class is used to process the level value.</p>
-	 *
-	 * <p>As a special case, if the <var>$value</var> parameter is
-	 * equal to the string "NULL", then the value <i>null</i> will
-	 * be returned.</p>
-	 *
-	 * <p>If any error occurs while converting the value to a level,
-	 * the <var>$defaultValue</var> parameter, which may be
-	 * <i>null</i>, is returned.</p>
-	 *
-	 * <p>Case of <var>$value</var> is insignificant for the level level, but is
-	 * significant for the class name part, if present.</p>
-	 *
-	 * @param string $value
-	 * @param LoggerLevel $defaultValue
-	 * @return LoggerLevel a {@link LoggerLevel} or null
-	 */
-	public static function toLevel($value, $defaultValue) {
-		if($value === null) {
-			return $defaultValue;
-		}
-		$hashIndex = strpos($value, '#');
-		if($hashIndex === false) {
-			if("NULL" == strtoupper($value)) {
-				return null;
-			} else {
-				// no class name specified : use standard Level class
-				return LoggerLevel::toLevel($value, $defaultValue);
-			}
-		}
-
-		$result = $defaultValue;
-
-		$clazz = substr($value, ($hashIndex + 1));
-		$levelName = substr($value, 0, $hashIndex);
-
-		// This is degenerate case but you never know.
-		if("NULL" == strtoupper($levelName)) {
-			return null;
-		}
-
-		$clazz = basename($clazz);
-
-		if(class_exists($clazz)) {
-			$result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue);
-			if(!$result instanceof LoggerLevel) {
-				$result = $defaultValue;
-			}
-		} 
-		return $result;
-	}
-	
-	
 	/** Converts the value to a level. Throws an exception if not possible. */
 	public static function toLevelEx($value) {
 		if ($value instanceof LoggerLevel) {
@@ -238,35 +125,6 @@ class LoggerOptionConverter {
 		return $level;
 	}
 
-	/**
-	 * @param string $value
-	 * @param float $default
-	 * @return float
-	 */
-	public static function toFileSize($value, $default) {
-		if($value === null) {
-			return $default;
-		}
-
-		$s = strtoupper(trim($value));
-		$multiplier = (float)1;
-		if(($index = strpos($s, 'KB')) !== false) {
-			$multiplier = 1024;
-			$s = substr($s, 0, $index);
-		} else if(($index = strpos($s, 'MB')) !== false) {
-			$multiplier = 1024 * 1024;
-			$s = substr($s, 0, $index);
-		} else if(($index = strpos($s, 'GB')) !== false) {
-			$multiplier = 1024 * 1024 * 1024;
-			$s = substr($s, 0, $index);
-		}
-		if(is_numeric($s)) {
-			return (float)$s * $multiplier;
-		} 
-		return $default;
-	}
-	
-
 	/**
 	 * Converts a value to a valid file size (integer).
 	 * 
@@ -337,115 +195,32 @@ class LoggerOptionConverter {
 		throw new LoggerException("Given value [" . var_export($value, true) . "] cannot be converted to string.");
 	}
 	
-	
 	/**
-	 * Find the value corresponding to <var>$key</var> in
-	 * <var>$props</var>. Then perform variable substitution on the
-	 * found value.
-	 *
-	 * @param string $key
-	 * @param array $props
-	 * @return string
-	 */
-	public static function findAndSubst($key, $props) {
-		$value = @$props[$key];
-
-		// If coming from the LoggerConfiguratorIni, some options were
-		// already mangled by parse_ini_file:
-		//
-		// not specified      => never reaches this code
-		// ""|off|false|null  => string(0) ""
-		// "1"|on|true        => string(1) "1"
-		// "true"             => string(4) "true"
-		// "false"            => string(5) "false"
-		// 
-		// As the integer 1 and the boolean true are therefore indistinguable
-		// it's up to the setter how to deal with it, they can not be cast
-		// into a boolean here. {@see toBoolean}
-		// Even an empty value has to be given to the setter as it has been
-		// explicitly set by the user and is different from an option which
-		// has not been specified and therefore keeps its default value.
-		//
-		// if(!empty($value)) {
-			return LoggerOptionConverter::substVars($value, $props);
-		// }
-	}
-
-	/**
-	 * Perform variable substitution in string <var>$val</var> from the
-	 * values of keys found with the {@link getSystemProperty()} method.
-	 * 
-	 * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
+	 * Performs value substitution for string options.
 	 * 
-	 * <p>For example, if the "MY_CONSTANT" contains "value", then
-	 * the call
-	 * <code>
-	 * $s = LoggerOptionConverter::substVars("Value of key is ${MY_CONSTANT}.");
-	 * </code>
-	 * will set the variable <i>$s</i> to "Value of key is value.".</p>
+	 * An option can contain PHP constants delimited by '${' and '}'.
 	 * 
-	 * <p>If no value could be found for the specified key, then the
-	 * <var>$props</var> parameter is searched, if the value could not
-	 * be found there, then substitution defaults to the empty string.</p>
+	 * E.g. for input string "some ${FOO} value", the method will attempt 
+	 * to substitute ${FOO} with the value of constant FOO if it exists.
 	 * 
-	 * <p>For example, if {@link getSystemProperty()} cannot find any value for the key
-	 * "inexistentKey", then the call
-	 * <code>
-	 * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
-	 * </code>
-	 * will set <var>$s</var> to "Value of inexistentKey is []".</p>
+	 * Therefore, if FOO is a constant, and it has value "bar", the resulting 
+	 * string will be "some bar value". 
 	 * 
-	 * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${" 
-	 * which is not balanced by a stop delimeter "}" and an empty string is returned.</p>
+	 * If the constant is not defined, it will be replaced by an empty string, 
+	 * and the resulting string will be "some  value". 
 	 * 
-	 * @param string $val The string on which variable substitution is performed.
-	 * @param array $props
+	 * @param string $string String on which to perform substitution.
 	 * @return string
 	 */
-	 // TODO: this method doesn't work correctly with key = true, it needs key = "true" which is odd
-	public static function substVars($val, $props = null) {
-		$sbuf = '';
-		$i = 0;
-		while(true) {
-			$j = strpos($val, self::DELIM_START, $i);
-			if($j === false) {
-				// no more variables
-				if($i == 0) { // this is a simple string
-					return $val;
-				} else { // add the tail string which contails no variables and return the result.
-					$sbuf .= substr($val, $i);
-					return $sbuf;
-				}
-			} else {
-			
-				$sbuf .= substr($val, $i, $j-$i);
-				$k = strpos($val, self::DELIM_STOP, $j);
-				if($k === false) {
-					// LoggerOptionConverter::substVars() has no closing brace. Opening brace
-					return '';
-				} else {
-					$j += self::DELIM_START_LEN;
-					$key = substr($val, $j, $k - $j);
-					// first try in System properties
-					$replacement = LoggerOptionConverter::getSystemProperty($key, null);
-					// then try props parameter
-					if($replacement == null and $props !== null) {
-						$replacement = @$props[$key];
-					}
-
-					if(!empty($replacement)) {
-						// Do variable substitution on the replacement string
-						// such that we can solve "Hello ${x2}" as "Hello p1" 
-						// the where the properties are
-						// x1=p1
-						// x2=${x1}
-						$recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props);
-						$sbuf .= $recursiveReplacement;
-					}
-					$i = $k + self::DELIM_STOP_LEN;
-				}
-			}
+	public static function substConstants($string) {
+		preg_match_all('/\${([^}]+)}/', $string, $matches);
+		
+		foreach($matches[1] as $key => $match) {
+			$match = trim($match);
+			$search = $matches[0][$key];
+			$replacement = defined($match) ? constant($match) : '';
+			$string = str_replace($search, $replacement, $string);
 		}
+		return $string;
 	}
-
 }
diff --git a/libraries/log4php.debug/helpers/LoggerPatternConverter.php b/libraries/log4php.debug/helpers/LoggerPatternConverter.php
deleted file mode 100644
index 1bf951e5faf5714b800207dd3debe5c21937a43c..0000000000000000000000000000000000000000
--- a/libraries/log4php.debug/helpers/LoggerPatternConverter.php
+++ /dev/null
@@ -1,134 +0,0 @@
-<?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
- */
-
-
-/**
- * LoggerPatternConverter is an abstract class that provides the formatting 
- * functionality that derived classes need.
- * 
- * <p>Conversion specifiers in a conversion patterns are parsed to
- * individual PatternConverters. Each of which is responsible for
- * converting a logging event in a converter specific manner.</p>
- * 
- * @version $Revision: 1166187 $
- * @package log4php
- * @subpackage helpers
- * @since 0.3
- */
-class LoggerPatternConverter {
-	
-	/**
-	 * Array for fast space padding
-	 * Used by {@link LoggerPatternConverter::spacePad()}.	
-	 */
-	private $spaces = array(
-		" ", // 1 space
-		"  ", // 2 spaces
-		"    ", // 4 spaces
-		"        ", // 8 spaces
-		"                ", // 16 spaces
-		"                                "); // 32 spaces 
-	 
-	/**
-	 * @var LoggerPatternConverter next converter in converter chain
-	 */
-	public $next = null;
-	
-	public $min = -1;
-	public $max = 0x7FFFFFFF;
-	public $leftAlign = false;
-
-	/**
-	 * Constructor 
-	 *
-	 * @param LoggerFormattingInfo $fi
-	 */
-	public function __construct($fi = null) {  
-		if($fi !== null) {
-			$this->min = $fi->min;
-			$this->max = $fi->max;
-			$this->leftAlign = $fi->leftAlign;
-		}
-	}
-  
-	/**
-	 * Derived pattern converters must override this method in order to
-	 * convert conversion specifiers in the correct way.
-	 *
-	 * @param LoggerLoggingEvent $event
-	 */
-	public function convert($event) {}
-
-	/**
-	 * A template method for formatting in a converter specific way.
-	 *
-	 * @param string &$sbuf string buffer
-	 * @param LoggerLoggingEvent $e
-	 */
-	public function format(&$sbuf, $e) {
-		$s = $this->convert($e);
-		
-		if($s == null or empty($s)) {
-			if(0 < $this->min) {
-				$this->spacePad($sbuf, $this->min);
-			}
-			return;
-		}
-		
-		$len = strlen($s);
-	
-		if($len > $this->max) {
-			$sbuf .= substr($s , 0, ($len - $this->max));
-		} else if($len < $this->min) {
-			if($this->leftAlign) {		
-				$sbuf .= $s;
-				$this->spacePad($sbuf, ($this->min - $len));
-			} else {
-				$this->spacePad($sbuf, ($this->min - $len));
-				$sbuf .= $s;
-			}
-		} else {
-			$sbuf .= $s;
-		}
-	}	
-
-	/**
-	 * Fast space padding method.
-	 *
-	 * @param string	&$sbuf	   string buffer
-	 * @param integer	$length	   pad length
-	 *
-	 * @todo reimplement using PHP string functions
-	 */
-	public function spacePad(&$sbuf, $length) {
-		while($length >= 32) {
-		  $sbuf .= $this->spaces[5];
-		  $length -= 32;
-		}
-		
-		for($i = 4; $i >= 0; $i--) {	
-			if(($length & (1<<$i)) != 0) {
-				$sbuf .= $this->spaces[$i];
-			}
-		}
-
-		// $sbuf = str_pad($sbuf, $length);
-	}
-}
diff --git a/libraries/log4php.debug/helpers/LoggerPatternParser.php b/libraries/log4php.debug/helpers/LoggerPatternParser.php
index cb04068983cccd20b534e746d340d8170e7fe9ed..2b41e0acec37adb033b8cc1e50efc7a550ae8b7d 100644
--- a/libraries/log4php.debug/helpers/LoggerPatternParser.php
+++ b/libraries/log4php.debug/helpers/LoggerPatternParser.php
@@ -25,7 +25,7 @@
  * <p>It is this class that parses conversion patterns and creates
  * a chained list of {@link LoggerPatternConverter} converters.</p>
  * 
- * @version $Revision: 1163520 $ 
+ * @version $Revision: 1395467 $ 
  * @package log4php
  * @subpackage helpers
  *
@@ -33,299 +33,205 @@
  */
 class LoggerPatternParser {
 
+	/** Escape character for conversion words in the conversion pattern. */
 	const ESCAPE_CHAR = '%';
 	
-	const LITERAL_STATE = 0;
-	const CONVERTER_STATE = 1;
-	const MINUS_STATE = 2;
-	const DOT_STATE = 3;
-	const MIN_STATE = 4;
-	const MAX_STATE = 5;
+	/** Maps conversion words to relevant converters. */
+	private $converterMap;
 	
-	const FULL_LOCATION_CONVERTER = 1000;
-	const METHOD_LOCATION_CONVERTER = 1001;
-	const CLASS_LOCATION_CONVERTER = 1002;
-	const FILE_LOCATION_CONVERTER = 1003;
-	const LINE_LOCATION_CONVERTER = 1004;
-	
-	const RELATIVE_TIME_CONVERTER = 2000;
-	const THREAD_CONVERTER = 2001;
-	const LEVEL_CONVERTER = 2002;
-	const NDC_CONVERTER = 2003;
-	const MESSAGE_CONVERTER = 2004;
+	/** Conversion pattern used in layout. */
+	private $pattern;
 	
-	const DATE_FORMAT_ISO8601 = 'Y-m-d H:i:s,u'; 
-	const DATE_FORMAT_ABSOLUTE = 'H:i:s';
-	const DATE_FORMAT_DATE = 'd M Y H:i:s,u';
-
-	private $state;
-	private $currentLiteral;
-	private $patternLength;
-	private $i;
+	/** Regex pattern used for parsing the conversion pattern. */
+	private $regex;
 	
-	/**
+	/** 
+	 * First converter in the chain. 
 	 * @var LoggerPatternConverter
 	 */
-	private $head = null;
-	 
-	/**
-	 * @var LoggerPatternConverter
-	 */
-	private $tail = null;
+	private $head;
 	
-	/**
-	 * @var LoggerFormattingInfo
-	 */
-	private $formattingInfo;
+	/** Last converter in the chain. */
+	private $tail;
 	
-	/**
-	 * @var string pattern to parse
+	public function __construct($pattern, $converterMap) {
+		$this->pattern = $pattern;
+		$this->converterMap = $converterMap;
+		
+		// Construct the regex pattern
+		$this->regex = 
+			'/' .                       // Starting regex pattern delimiter
+			self::ESCAPE_CHAR .         // Character which marks the start of the conversion pattern
+			'(?P<modifiers>[0-9.-]*)' . // Format modifiers (optional)
+			'(?P<word>[a-zA-Z]+)' .     // The conversion word
+			'(?P<option>{[^}]*})?' .    // Conversion option in braces (optional)
+			'/';                        // Ending regex pattern delimiter
+	}
+	
+	/** 
+	 * Parses the conversion pattern string, converts it to a chain of pattern
+	 * converters and returns the first converter in the chain.
+	 * 
+	 * @return LoggerPatternConverter
 	 */
-	private $pattern;
+	public function parse() {
+		
+		// Skip parsing if the pattern is empty
+		if (empty($this->pattern)) {
+			$this->addLiteral('');
+			return $this->head;
+		}
+		
+		// Find all conversion words in the conversion pattern
+		$count = preg_match_all($this->regex, $this->pattern, $matches, PREG_OFFSET_CAPTURE);
+		if ($count === false) {
+			$error = error_get_last();
+			throw new LoggerException("Failed parsing layotut pattern: {$error['message']}");
+		}
+		
+		$prevEnd = 0;
+		
+		foreach($matches[0] as $key => $item) {
+			
+			// Locate where the conversion command starts and ends
+			$length = strlen($item[0]);
+			$start = $item[1];
+			$end = $item[1] + $length;
+		
+			// Find any literal expressions between matched commands
+			if ($start > $prevEnd) {
+				$literal = substr($this->pattern, $prevEnd, $start - $prevEnd);
+				$this->addLiteral($literal);
+			}
+			
+			// Extract the data from the matched command
+			$word = !empty($matches['word'][$key]) ? $matches['word'][$key][0] : null;
+			$modifiers = !empty($matches['modifiers'][$key]) ? $matches['modifiers'][$key][0] : null;
+			$option = !empty($matches['option'][$key]) ? $matches['option'][$key][0] : null;
+			
+			// Create a converter and add it to the chain
+			$this->addConverter($word, $modifiers, $option);
+			
+			$prevEnd = $end;
+		}
 
-	/**
-	 * Constructor 
-	 *
-	 * @param string $pattern
+		// Add any trailing literals
+		if ($end < strlen($this->pattern)) {
+			$literal = substr($this->pattern, $end);
+			$this->addLiteral($literal);
+		}
+		
+		return $this->head;
+	}
+	
+	/** 
+	 * Adds a literal converter to the converter chain. 
+	 * @param string $string The string for the literal converter.
 	 */
-	public function __construct($pattern) {
-		$this->pattern = $pattern;
-		$this->patternLength =	strlen($pattern);
-		$this->formattingInfo = new LoggerFormattingInfo();
-		$this->state = self::LITERAL_STATE;
+	private function addLiteral($string) {
+		$converter = new LoggerPatternConverterLiteral($string);
+		$this->addToChain($converter);
 	}
-
+	
 	/**
-	 * @param LoggerPatternConverter $pc
+	 * Adds a non-literal converter to the converter chain.
+	 * 
+	 * @param string $word The conversion word, used to determine which 
+	 *  converter will be used.
+	 * @param string $modifiers Formatting modifiers.
+	 * @param string $option Option to pass to the converter.
 	 */
-	public function addToList($pc) {
-		if($this->head == null) {
-			$this->head = $pc;
-			$this->tail = $this->head;
+	private function addConverter($word, $modifiers, $option) {
+ 		$formattingInfo = $this->parseModifiers($modifiers);
+		$option = trim($option, "{} ");
+		
+		if (isset($this->converterMap[$word])) {
+			$converter = $this->getConverter($word, $formattingInfo, $option);
+			$this->addToChain($converter);	
 		} else {
-			$this->tail->next = $pc;
-			$this->tail = $this->tail->next;
+			trigger_error("log4php: Invalid keyword '%$word' in converison pattern. Ignoring keyword.", E_USER_WARNING);
 		}
 	}
-
+	
 	/**
-	 * @return string
+	 * Determines which converter to use based on the conversion word. Creates 
+	 * an instance of the converter using the provided formatting info and 
+	 * option and returns it.
+	 * 
+	 * @param string $word The conversion word.
+	 * @param LoggerFormattingInfo $info Formatting info.
+	 * @param string $option Converter option.
+	 * 
+	 * @throws LoggerException 
+	 * 
+	 * @return LoggerPatternConverter
 	 */
-	public function extractOption() {
-		if(($this->i < $this->patternLength) and ($this->pattern{$this->i} == '{')) {
-			$end = strpos($this->pattern, '}' , $this->i);
-			if($end !== false) {
-				$r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1));
-				$this->i= $end + 1;
-				return $r;
-			}
+	private function getConverter($word, $info, $option) {
+		if (!isset($this->converterMap[$word])) {
+			throw new LoggerException("Invalid keyword '%$word' in converison pattern. Ignoring keyword.");
+		}
+		
+		$converterClass = $this->converterMap[$word];
+		if(!class_exists($converterClass)) {
+			throw new LoggerException("Class '$converterClass' does not exist.");
 		}
-		return null;
+		
+		$converter = new $converterClass($info, $option);
+		if(!($converter instanceof LoggerPatternConverter)) {
+			throw new LoggerException("Class '$converterClass' is not an instance of LoggerPatternConverter.");
+		}
+		
+		return $converter;
 	}
-
-	/**
-	 * The option is expected to be in decimal and positive. In case of
-	 * error, zero is returned.	 
-	 */
-	public function extractPrecisionOption() {
-		$opt = $this->extractOption();
-		$r = 0;
-		if($opt !== null) {
-			if(is_numeric($opt)) {
-				$r = (int)$opt;
-				if($r <= 0) {
-					$r = 0;
-				}
-			}
+	
+	/** Adds a converter to the chain and updates $head and $tail pointers. */
+	private function addToChain(LoggerPatternConverter $converter) {
+		if (!isset($this->head)) {
+			$this->head = $converter;
+			$this->tail = $this->head;
+		} else {
+			$this->tail->next = $converter;
+			$this->tail = $this->tail->next;
 		}
-		return $r;
 	}
-
 	
-	/** Parser.
+	/**
+	 * Parses the formatting modifiers and produces the corresponding 
+	 * LoggerFormattingInfo object.
 	 * 
-	 * @return LoggerPatternConverter Returns $this->head.
+	 * @param string $modifier
+	 * @return LoggerFormattingInfo
+	 * @throws LoggerException
 	 */
-	public function parse() {
-		$c = '';
-		$this->i = 0;
-		$this->currentLiteral = '';
-		while($this->i < $this->patternLength) {
-			$c = $this->pattern{$this->i++};
-
-			switch($this->state) {
-				case self::LITERAL_STATE:
-					// In literal state, the last char is always a literal.
-					if($this->i == $this->patternLength) {
-						$this->currentLiteral .= $c;
-						continue;
-					}
-					if($c == self::ESCAPE_CHAR) {
-						// peek at the next char.
-						switch($this->pattern{$this->i}) {
-							case self::ESCAPE_CHAR:
-								$this->currentLiteral .= $c;
-								$this->i++; // move pointer
-								break;
-							case 'n':
-								$this->currentLiteral .= PHP_EOL;
-								$this->i++; // move pointer
-								break;
-							default:
-								if(strlen($this->currentLiteral) != 0) {
-									$this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
-								}
-								$this->currentLiteral = $c;
-								$this->state = self::CONVERTER_STATE;
-								$this->formattingInfo->reset();
-						}
-					} else {
-						$this->currentLiteral .= $c;
-					}
-					break;
-				case self::CONVERTER_STATE:
-						$this->currentLiteral .= $c;
-						switch($c) {
-						case '-':
-							$this->formattingInfo->leftAlign = true;
-							break;
-						case '.':
-							$this->state = self::DOT_STATE;
-								break;
-						default:
-							if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
-								$this->formattingInfo->min = ord($c) - ord('0');
-								$this->state = self::MIN_STATE;
-							} else {
-								$this->finalizeConverter($c);
-							}
-						} // switch
-					break;
-				case self::MIN_STATE:
-					$this->currentLiteral .= $c;
-					if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
-						$this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord($c) - ord('0'));
-					} else if ($c == '.') {
-						$this->state = self::DOT_STATE;
-					} else {
-						$this->finalizeConverter($c);
-					}
-					break;
-				case self::DOT_STATE:
-					$this->currentLiteral .= $c;
-					if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
-						$this->formattingInfo->max = ord($c) - ord('0');
-						$this->state = self::MAX_STATE;
-					} else {
-						$this->state = self::LITERAL_STATE;
-					}
-					break;
-				case self::MAX_STATE:
-					$this->currentLiteral .= $c;
-					if(ord($c) >= ord('0') and ord($c) <= ord('9')) {
-						$this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0'));
-					} else {
-						$this->finalizeConverter($c);
-						$this->state = self::LITERAL_STATE;
-					}
-					break;
-			} // switch
-		} // while
-		if(strlen($this->currentLiteral) != 0) {
-			$this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
+	private function parseModifiers($modifiers) {
+		$info = new LoggerFormattingInfo();
+	
+		// If no modifiers are given, return default values
+		if (empty($modifiers)) {
+			return $info;
 		}
-		return $this->head;
-	}
-
-	public function finalizeConverter($c) {
-		$pc = null;
-		switch($c) {
-			case 'c':
-				$pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption());
-				$this->currentLiteral = '';
-				break;
-			case 'C':
-				$pc = new LoggerClassNamePatternConverter($this->formattingInfo, self::CLASS_LOCATION_CONVERTER);
-				$this->currentLiteral = '';
-				break;
-			case 'd':
-				$dateFormatStr = self::DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT;
-				$dOpt = $this->extractOption();
-
-				if($dOpt !== null)
-					$dateFormatStr = $dOpt;
-					
-				if($dateFormatStr == 'ISO8601') {
-					$df = self::DATE_FORMAT_ISO8601;
-				} else if($dateFormatStr == 'ABSOLUTE') {
-					$df = self::DATE_FORMAT_ABSOLUTE;
-				} else if($dateFormatStr == 'DATE') {
-					$df = self::DATE_FORMAT_DATE;
-				} else {
-					$df = $dateFormatStr;
-					if($df == null) {
-						$df = self::DATE_FORMAT_ISO8601;
-					}
-				}
-				$pc = new LoggerDatePatternConverter($this->formattingInfo, $df);
-				$this->currentLiteral = '';
-				break;
-			case 'F':
-				$pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FILE_LOCATION_CONVERTER);
-				$this->currentLiteral = '';
-				break;
-			case 'l':
-				$pc = new LoggerLocationPatternConverter($this->formattingInfo, self::FULL_LOCATION_CONVERTER);
-				$this->currentLiteral = '';
-				break;
-			case 'L':
-				$pc = new LoggerLocationPatternConverter($this->formattingInfo, self::LINE_LOCATION_CONVERTER);
-				$this->currentLiteral = '';
-				break;
-			case 'm':
-				$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::MESSAGE_CONVERTER);
-				$this->currentLiteral = '';
-				break;
-			case 'M':
-				$pc = new LoggerLocationPatternConverter($this->formattingInfo, self::METHOD_LOCATION_CONVERTER);
-				$this->currentLiteral = '';
-				break;
-			case 'p':
-				$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::LEVEL_CONVERTER);
-				$this->currentLiteral = '';
-				break;
-			case 'r':
-				$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::RELATIVE_TIME_CONVERTER);
-				$this->currentLiteral = '';
-				break;
-			case 't':
-				$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::THREAD_CONVERTER);
-				$this->currentLiteral = '';
-				break;
-			case 'x':
-				$pc = new LoggerBasicPatternConverter($this->formattingInfo, self::NDC_CONVERTER);
-				$this->currentLiteral = '';
-				break;
-			case 'X':
-				$xOpt = $this->extractOption();
-				$pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt);
-				$this->currentLiteral = '';
-				break;
-			default:
-				$pc = new LoggerLiteralPatternConverter($this->currentLiteral);
-				$this->currentLiteral = '';
+	
+		// Validate
+		$pattern = '/^(-?[0-9]+)?\.?-?[0-9]+$/';
+		if (!preg_match($pattern, $modifiers)) {
+			trigger_error("log4php: Invalid modifier in conversion pattern: [$modifiers]. Ignoring modifier.", E_USER_WARNING);
+			return $info;
 		}
-		$this->addConverter($pc);
-	}
-
-	public function addConverter($pc) {
-		$this->currentLiteral = '';
-		// Add the pattern converter to the list.
-		$this->addToList($pc);
-		// Next pattern is assumed to be a literal.
-		$this->state = self::LITERAL_STATE;
-		// Reset formatting info
-		$this->formattingInfo->reset();
+	
+		$parts = explode('.', $modifiers);
+	
+		if (!empty($parts[0])) {
+			$minPart = (integer) $parts[0];
+			$info->min = abs($minPart);
+			$info->padLeft = ($minPart > 0);
+		}
+	
+		if (!empty($parts[1])) {
+			$maxPart = (integer) $parts[1];
+			$info->max = abs($maxPart);
+			$info->trimLeft = ($maxPart < 0);
+		}
+	
+		return $info;
 	}
 }
-
diff --git a/libraries/log4php.debug/helpers/LoggerUtils.php b/libraries/log4php.debug/helpers/LoggerUtils.php
new file mode 100644
index 0000000000000000000000000000000000000000..bc7366e6ad155917892f25d19b3d82aacd972565
--- /dev/null
+++ b/libraries/log4php.debug/helpers/LoggerUtils.php
@@ -0,0 +1,123 @@
+<?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
+ */
+
+/**
+ * Contains various helper methods.
+ * 
+ * @package log4php
+ * @subpackage helpers
+ * @since 2.3
+ */
+class LoggerUtils {
+	
+	/**
+ 	 * Splits a fully qualified class name into fragments delimited by the 
+ 	 * namespace separator (\). 
+ 	 * 
+ 	 * For backward compatibility, a dot (.) can be used as a delimiter as
+ 	 * well. 
+	 * 
+	 * @param string $name
+	 * 
+	 * @return array Class name split into fragments.
+	 */
+	public static function tokenizeClassName($name) {
+		$name = str_replace('.', '\\', $name);
+		$name = trim($name, ' \\');
+		$fragments = explode('\\', $name);
+		
+		foreach($fragments as $key => $fragment) {
+			if (trim($fragment) === '') {
+				unset($fragments[$key]);
+			}
+		}
+		
+		return $fragments;
+	}
+	
+	/**
+	 * Attempts to shorten the given class name to the desired length.
+	 * 
+	 * This is done by separating the class name into fragments (delimited
+	 * by \ or .) and trimming individual fragments, starting with the left,
+	 * until desired length has been reached. 
+	 * 
+	 * The final fragment (i.e. class name) will never be shortened so the 
+	 * result may still be longer than given length.
+	 * 
+	 * @param string $name The (qualified) class name.  
+	 * @param integer $length The length to shorten to. If null or 0 is given,
+	 * the name will be returned without shortening. 
+	 */
+	public static function shortenClassName($name, $length) {
+		if ($length === null || $length < 0) {
+			return $name;
+		}
+		
+		$name = str_replace('.', '\\', $name);
+		$name = trim($name, ' \\');
+		
+		// Check if any shortening is required
+		$currentLength = strlen($name);
+		if ($currentLength <= $length) {
+			return $name;
+		}
+	
+		// Split name into fragments
+		$fragments = explode('\\', $name);
+
+		// If zero length is specified, return only last fragment
+		if ($length == 0) {
+			return array_pop($fragments);
+		}
+		
+		// If the name splits to only one fragment, then it cannot be shortened
+		$count = count($fragments);
+		if ($count == 1) {
+			return $name;
+		}
+	
+		foreach($fragments as $key => &$fragment) {
+	
+			// Never shorten last fragment
+			if ($key == $count - 1) {
+				break;
+			}
+	
+			// Check for empty fragments (shouldn't happen but it's possible)
+			$fragLen = strlen($fragment);
+			if ($fragLen <= 1) {
+				continue;
+			}
+	
+			// Shorten fragment to one character and check if total length satisfactory
+			$fragment = substr($fragment, 0, 1);
+			$currentLength = $currentLength - $fragLen + 1;
+	
+			if ($currentLength <= $length) {
+				break;
+			}
+		}
+		unset($fragment);
+	
+		return implode('\\', $fragments);
+	}
+}
+
diff --git a/libraries/log4php.debug/layouts/LoggerLayoutHtml.php b/libraries/log4php.debug/layouts/LoggerLayoutHtml.php
index 3f9df87b68238c3a7432c15e8c356e80926b9472..b7b8d295e18e2726a4d3818f6d640bf62bb9ab9a 100644
--- a/libraries/log4php.debug/layouts/LoggerLayoutHtml.php
+++ b/libraries/log4php.debug/layouts/LoggerLayoutHtml.php
@@ -42,7 +42,7 @@
  *    0    8318   INFO  root       Hello World!
  * </pre>
  * 
- * @version $Revision: 1213283 $
+ * @version $Revision: 1379731 $
  * @package log4php
  * @subpackage layouts
  */
@@ -122,7 +122,7 @@ class LoggerLayoutHtml extends LoggerLayout {
 		$sbuf = PHP_EOL . "<tr>" . PHP_EOL;
 	
 		$sbuf .= "<td>";
-		$sbuf .= $event->getTime();
+		$sbuf .= round(1000 * $event->getRelativeTime());
 		$sbuf .= "</td>" . PHP_EOL;
 	
 		$sbuf .= "<td title=\"" . $event->getThreadName() . " thread\">";
diff --git a/libraries/log4php.debug/layouts/LoggerLayoutPattern.php b/libraries/log4php.debug/layouts/LoggerLayoutPattern.php
index 4125f5ae38b06df7ed694b996c57d2dfd31d6233..6e31f98c6481271be6be6ab2fc9a0874d478b82c 100644
--- a/libraries/log4php.debug/layouts/LoggerLayoutPattern.php
+++ b/libraries/log4php.debug/layouts/LoggerLayoutPattern.php
@@ -19,149 +19,140 @@
  */
 
 /**
- * A flexible layout configurable with pattern string.
- *
- * <p>Example:</p>
- * 
- * {@example ../../examples/php/layout_pattern.php 19}<br>
- * 
- * <p>with the following properties file:</p>
- * 
- * {@example ../../examples/resources/layout_pattern.properties 18}<br>
- * 
- * <p>would print the following:</p>
- * 
- * <pre>
- * 2009-09-09 00:27:35,787 [INFO] root: Hello World! (at src/examples/php/layout_pattern.php line 6)
- * 2009-09-09 00:27:35,787 [DEBUG] root: Second line (at src/examples/php/layout_pattern.php line 7)
- * </pre>
- *
- * <p>The conversion pattern is closely related to the conversion pattern of the printf function in C.
- * A conversion pattern 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 
- * format modifiers and a conversion character.</p>
- * 
- * <p>The conversion character specifies the type of data, e.g. category, priority, date, thread name. 
- * The format modifiers control such things as field width, padding, left and right justification.</p>
+ * A flexible layout configurable with a pattern string.
  * 
- * <p>Note that there is no explicit separator between text and conversion specifiers.</p>
+ * Configurable parameters:
  * 
- * <p>The pattern parser knows when it has reached the end of a conversion specifier when it reads a conversion character. 
- * In the example above the conversion specifier %-5p means the priority of the logging event should be 
- * left justified to a width of five characters.</p> 
- *
- * Not all log4j conversion characters are implemented. The recognized conversion characters are:
- * - <b>c</b> Used to output the category of the logging event. The category conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets. 
- *         If a precision specifier is given, then only the corresponding number of right most components of the category name will be printed. 
- *         By default the category name is printed in full. 
- *         For example, for the category name "a.b.c" the pattern %c{2} will output "b.c". 
- * - <b>C</b> Used to output the fully qualified class name of the caller issuing the logging request. 
- *         This conversion specifier can be optionally followed by precision specifier, that is a decimal constant in brackets. 
- *         If a precision specifier is given, then only the corresponding number of right most components of the class name will be printed. 
- *         By default the class name is output in fully qualified form. 
- *         For example, for the class name "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass". 
- * - <b>d</b> Used to output the date of the logging event. 
- *         The date conversion specifier may be followed by a date format specifier enclosed between braces.
- *         The format specifier follows the {@link PHP_MANUAL#date} function.
- *         Note that the special character <b>u</b> is used to as microseconds replacement (to avoid replacement,
- *         use <b>\u</b>).  
- *         For example, %d{H:i:s,u} or %d{d M Y H:i:s,u}. If no date format specifier is given then ISO8601 format is assumed. 
- *         The date format specifier admits the same syntax as the time pattern string of the SimpleDateFormat. 
- *         It is recommended to use the predefined log4php date formatters. 
- *         These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying 
- *         AbsoluteTimeDateFormat, DateTimeDateFormat and respectively ISO8601DateFormat. 
- *         For example, %d{ISO8601} or %d{ABSOLUTE}. 
- * - <b>F</b> Used to output the file name where the logging request was issued. 
- * - <b>l</b> Used to output location information of the caller which generated the logging event. 
- * - <b>L</b> Used to output the line number from where the logging request was issued.
- * - <b>m</b> Used to output the application supplied message associated with the logging event.
- * - <b>M</b> Used to output the method name where the logging request was issued.  
- * - <b>p</b> Used to output the priority of the logging event.
- * - <b>r</b> Used to output the number of milliseconds elapsed since the start of 
- *            the application until the creation of the logging event. 
- * - <b>t</b> Used to output the name of the thread that generated the logging event.
- * - <b>x</b> Used to output the NDC (nested diagnostic context) associated with 
- *            the thread that generated the logging event.  
- * - <b>X</b> Used to output the MDC (mapped diagnostic context) associated with 
- *            the thread that generated the logging event. 
- *            The X conversion character must be followed by the key for the map placed between braces, 
- *            as in <i>%X{clientNumber}</i> where clientNumber is the key.
- *            The value in the MDC corresponding to the key will be output.
- *            See {@link LoggerMDC} class for more details. 
- * - <b>%</b> The sequence %% outputs a single percent sign.  
- *
- * <p>By default the relevant information is output as is. 
- *  However, with the aid of format modifiers it is possible to change the minimum field width, 
- *  the maximum field width and justification.</p> 
- *
- * <p>The optional format modifier is placed between the percent sign and the conversion character.</p>
- * <p>The first optional format modifier is the left justification flag which is just the minus (-) character. 
- *  Then comes the optional minimum field width modifier. 
- *  This is a decimal constant 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 maximum field width modifier which is designated by a period 
- *  followed by a decimal constant. 
- *  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>Below are various format modifier examples for the category conversion specifier.</p> 
- * <pre>
- *   Format modifier  left justify  minimum width  maximum width  comment
- *   %20c             false         20             none           Left pad with spaces if the category name 
- *                                                                is less than 20 characters long.
- *   %-20c            true          20             none           Right pad with spaces if the category name 
- *                                                                is less than 20 characters long.  
- *   %.30c            NA            none           30             Truncate from the beginning if the category name 
- *                                                                is longer than 30 characters.  
- *   %20.30c          false         20             30             Left pad with spaces if the category name 
- *                                                                is shorter than 20 characters. 
- *                                                                However, if category name is longer than 30 chars, 
- *                                                                then truncate from the beginning.  
- *   %-20.30c         true          20             30             Right pad with spaces if the category name is 
- *                                                                shorter than 20 chars. 
- *                                                                However, if category name is longer than 30 chars, 
- *                                                                then truncate from the beginning.  
- * </pre>
+ * * converionPattern - A string which controls the formatting of logging 
+ *   events. See docs for full specification.
  * 
- * @version $Revision: 1213283 $
  * @package log4php
  * @subpackage layouts
- * @since 0.3 
+ * @version $Revision: 1395470 $
  */
 class LoggerLayoutPattern extends LoggerLayout {
-	/** Default conversion Pattern */
-	const DEFAULT_CONVERSION_PATTERN = '%m%n';
+	
+	/** Default conversion pattern */
+	const DEFAULT_CONVERSION_PATTERN = '%date %-5level %logger %message%newline';
 
 	/** Default conversion TTCC Pattern */
 	const TTCC_CONVERSION_PATTERN = '%d [%t] %p %c %x - %m%n';
 
 	/** The conversion pattern. */ 
 	protected $pattern = self::DEFAULT_CONVERSION_PATTERN;
+	
+	/** Maps conversion keywords to the relevant converter (default implementation). */
+	protected static $defaultConverterMap = array(
+		'c' => 'LoggerPatternConverterLogger',
+		'lo' => 'LoggerPatternConverterLogger',
+		'logger' => 'LoggerPatternConverterLogger',
+		
+		'C' => 'LoggerPatternConverterClass',
+		'class' => 'LoggerPatternConverterClass',
+		
+		'cookie' => 'LoggerPatternConverterCookie',
+		
+		'd' => 'LoggerPatternConverterDate',
+		'date' => 'LoggerPatternConverterDate',
+		
+		'e' => 'LoggerPatternConverterEnvironment',
+		'env' => 'LoggerPatternConverterEnvironment',
+		
+		'ex' => 'LoggerPatternConverterThrowable',
+		'exception' => 'LoggerPatternConverterThrowable',
+		'throwable' => 'LoggerPatternConverterThrowable',
+		
+		'F' => 'LoggerPatternConverterFile',
+		'file' => 'LoggerPatternConverterFile',
+			
+		'l' => 'LoggerPatternConverterLocation',
+		'location' => 'LoggerPatternConverterLocation',
+		
+		'L' => 'LoggerPatternConverterLine',
+		'line' => 'LoggerPatternConverterLine',
+		
+		'm' => 'LoggerPatternConverterMessage',
+		'msg' => 'LoggerPatternConverterMessage',
+		'message' => 'LoggerPatternConverterMessage',
+		
+		'M' => 'LoggerPatternConverterMethod',
+		'method' => 'LoggerPatternConverterMethod',
+		
+		'n' => 'LoggerPatternConverterNewLine',
+		'newline' => 'LoggerPatternConverterNewLine',
+		
+		'p' => 'LoggerPatternConverterLevel',
+		'le' => 'LoggerPatternConverterLevel',
+		'level' => 'LoggerPatternConverterLevel',
+	
+		'r' => 'LoggerPatternConverterRelative',
+		'relative' => 'LoggerPatternConverterRelative',
+		
+		'req' => 'LoggerPatternConverterRequest',
+		'request' => 'LoggerPatternConverterRequest',
+		
+		's' => 'LoggerPatternConverterServer',
+		'server' => 'LoggerPatternConverterServer',
+		
+		'ses' => 'LoggerPatternConverterSession',
+		'session' => 'LoggerPatternConverterSession',
+		
+		'sid' => 'LoggerPatternConverterSessionID',
+		'sessionid' => 'LoggerPatternConverterSessionID',
+	
+		't' => 'LoggerPatternConverterProcess',
+		'pid' => 'LoggerPatternConverterProcess',
+		'process' => 'LoggerPatternConverterProcess',
+		
+		'x' => 'LoggerPatternConverterNDC',
+		'ndc' => 'LoggerPatternConverterNDC',
+			
+		'X' => 'LoggerPatternConverterMDC',
+		'mdc' => 'LoggerPatternConverterMDC',
+	);
 
+	/** Maps conversion keywords to the relevant converter. */
+	protected $converterMap = array();
+	
 	/** 
 	 * Head of a chain of Converters.
 	 * @var LoggerPatternConverter 
 	 */
 	private $head;
 
+	/** Returns the default converter map. */
+	public static function getDefaultConverterMap() {
+		return self::$defaultConverterMap;
+	}
+	
+	/** Constructor. Initializes the converter map. */
+	public function __construct() {
+		$this->converterMap = self::$defaultConverterMap;
+	}
+	
 	/**
-	 * Set the <b>ConversionPattern</b> option. This is the string which
+	 * Sets the conversionPattern option. This is the string which
 	 * controls formatting and consists of a mix of literal content and
 	 * conversion specifiers.
+	 * @param array $conversionPattern
 	 */
 	public function setConversionPattern($conversionPattern) {
 		$this->pattern = $conversionPattern;
-		$patternParser = new LoggerPatternParser($this->pattern);
-		$this->head = $patternParser->parse();
 	}
-
+	
+	/**
+	 * Processes the conversion pattern and creates a corresponding chain of 
+	 * pattern converters which will be used to format logging events. 
+	 */
+	public function activateOptions() {
+		if (!isset($this->pattern)) {
+			throw new LoggerException("Mandatory parameter 'conversionPattern' is not set.");
+		}
+		
+		$parser = new LoggerPatternParser($this->pattern, $this->converterMap);
+		$this->head = $parser->parse();
+	}
+	
 	/**
 	 * Produces a formatted string as specified by the conversion pattern.
 	 *
@@ -170,36 +161,11 @@ class LoggerLayoutPattern extends LoggerLayout {
 	 */
 	public function format(LoggerLoggingEvent $event) {
 		$sbuf = '';
-		$c = $this->head;
-		while ($c !== null) {
-			$c->format($sbuf, $event);
-			$c = $c->next;
+		$converter = $this->head;
+		while ($converter !== null) {
+			$converter->format($sbuf, $event);
+			$converter = $converter->next;
 		}
 		return $sbuf;
 	}
-	
-	/**
-	 * Returns an array with the formatted elements.
-	 * 
-	 * This method is mainly used for the prepared statements of {@see LoggerAppenderPDO}.
-	 * 
-	 * It requires {@link $this->pattern} to be a comma separated string of patterns like
-	 * e.g. <code>%d,%c,%p,%m,%t,%F,%L</code>.
-	 * 
-	 * @return array(string)   An array of the converted elements i.e. timestamp, message, filename etc.
-	 */
-	public function formatToArray(LoggerLoggingEvent $event) {
-		$results = array();
-		$c = $this->head;
-		while ($c !== null) {
-			if ( ! $c instanceOf LoggerLiteralPatternConverter) {
-				$sbuf = null;
-				$c->format($sbuf, $event);
-				$results[] = $sbuf;
-			}
-			$c = $c->next;
-		}
-		return $results;
-	}
-	
 }
diff --git a/libraries/log4php.debug/layouts/LoggerLayoutSerialized.php b/libraries/log4php.debug/layouts/LoggerLayoutSerialized.php
index 7b2da0658aa47bf0e6126abf3ee20dcf611759ea..a74e223ebb0ce63553dbe9e303dd307b7528dcda 100644
--- a/libraries/log4php.debug/layouts/LoggerLayoutSerialized.php
+++ b/libraries/log4php.debug/layouts/LoggerLayoutSerialized.php
@@ -25,7 +25,7 @@
  * - locationInfo - If set to true, the event's location information will also
  *                  be serialized (slow, defaults to false).
  * 
- * @version $Revision: 1059292 $
+ * @version $Revision: 1334369 $
  * @package log4php
  * @subpackage layouts
  * @since 2.2
diff --git a/libraries/log4php.debug/layouts/LoggerLayoutTTCC.php b/libraries/log4php.debug/layouts/LoggerLayoutTTCC.php
index 027d54d7053fbb251e7cd4b81dcb6b3648f168ab..6b4761ab58dd32299b0e493ef2f636ade415ad7a 100644
--- a/libraries/log4php.debug/layouts/LoggerLayoutTTCC.php
+++ b/libraries/log4php.debug/layouts/LoggerLayoutTTCC.php
@@ -44,9 +44,12 @@
  * The above would print:<br>
  * <samp>02:28 [13714] INFO root - Hello World!</samp>
  *
- * @version $Revision: 1213283 $
+ * @version $Revision: 1302503 $
  * @package log4php
  * @subpackage layouts
+ * 
+ * @deprecated LoggerLayout TTCC is deprecated and will be removed in a future release. Please use 
+ *   LoggerLayoutPattern instead. 
  */
 class LoggerLayoutTTCC extends LoggerLayout {
 
@@ -68,6 +71,7 @@ class LoggerLayoutTTCC extends LoggerLayout {
 	 * @see dateFormat
 	 */
 	public function __construct($dateFormat = '') {
+		$this->warn("LoggerLayout TTCC is deprecated and will be removed in a future release. Please use LoggerLayoutPattern instead.");
 		if (!empty($dateFormat)) {
 			$this->dateFormat = $dateFormat;
 		}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverter.php b/libraries/log4php.debug/pattern/LoggerPatternConverter.php
new file mode 100644
index 0000000000000000000000000000000000000000..f7a705090291446be8d855f288dd815957ce6a96
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverter.php
@@ -0,0 +1,131 @@
+<?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
+ */
+
+/**
+ * LoggerPatternConverter is an abstract class that provides the formatting 
+ * functionality that derived classes need.
+ * 
+ * <p>Conversion specifiers in a conversion patterns are parsed to
+ * individual PatternConverters. Each of which is responsible for
+ * converting a logging event in a converter specific manner.</p>
+ * 
+ * @version $Revision: 1326626 $
+ * @package log4php
+ * @subpackage helpers
+ * @since 0.3
+ */
+abstract class LoggerPatternConverter {
+	
+	/**
+	 * Next converter in the converter chain.
+	 * @var LoggerPatternConverter 
+	 */
+	public $next = null;
+	
+	/**
+	 * Formatting information, parsed from pattern modifiers. 
+	 * @var LoggerFormattingInfo
+	 */
+	protected $formattingInfo;
+	
+	/**
+	 * Converter-specific formatting options.
+	 * @var array
+	 */
+	protected $option;
+
+	/**
+	 * Constructor 
+	 * @param LoggerFormattingInfo $formattingInfo
+	 * @param array $option
+	 */
+	public function __construct(LoggerFormattingInfo $formattingInfo = null, $option = null) {  
+		$this->formattingInfo = $formattingInfo;
+		$this->option = $option;
+		$this->activateOptions();
+	}
+	
+	/**
+	 * Called in constructor. Converters which need to process the options 
+	 * can override this method. 
+	 */
+	public function activateOptions() { }
+  
+	/**
+	 * Converts the logging event to the desired format. Derived pattern 
+	 * converters must implement this method.
+	 *
+	 * @param LoggerLoggingEvent $event
+	 */
+	abstract public function convert(LoggerLoggingEvent $event);
+
+	/**
+	 * Converts the event and formats it according to setting in the 
+	 * Formatting information object.
+	 *
+	 * @param string &$sbuf string buffer to write to
+	 * @param LoggerLoggingEvent $event Event to be formatted.
+	 */
+	public function format(&$sbuf, $event) {
+		$string = $this->convert($event);
+		
+		if (!isset($this->formattingInfo)) {
+			$sbuf .= $string;
+			return;	
+		}
+		
+		$fi = $this->formattingInfo;
+		
+		// Empty string
+		if($string === '' || is_null($string)) {
+			if($fi->min > 0) {
+				$sbuf .= str_repeat(' ', $fi->min);
+			}
+			return;
+		}
+		
+		$len = strlen($string);
+	
+		// Trim the string if needed
+		if($len > $fi->max) {
+			if ($fi->trimLeft) {
+				$sbuf .= substr($string, $len - $fi->max, $fi->max);
+			} else {
+				$sbuf .= substr($string , 0, $fi->max);
+			}
+		}
+		
+		// Add padding if needed
+		else if($len < $fi->min) {
+			if($fi->padLeft) {
+				$sbuf .= str_repeat(' ', $fi->min - $len);
+				$sbuf .= $string;
+			} else {
+				$sbuf .= $string;
+				$sbuf .= str_repeat(' ', $fi->min - $len);
+			}
+		}
+		
+		// No action needed
+		else {
+			$sbuf .= $string;
+		}
+	}
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterClass.php b/libraries/log4php.debug/pattern/LoggerPatternConverterClass.php
new file mode 100644
index 0000000000000000000000000000000000000000..80ecb76a0d2da89ccda04fd0101a8dca02b4f06a
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterClass.php
@@ -0,0 +1,64 @@
+<?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 fully qualified class name of the class from which the logging 
+ * request was issued.
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterClass extends LoggerPatternConverter {
+
+	/** Length to which to shorten the class name. */
+	private $length;
+	
+	/** Holds processed class names. */
+	private $cache = array();
+	
+	public function activateOptions() {
+		// Parse the option (desired output length)
+		if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) {
+			$this->length = (integer) $this->option;
+		}
+	}
+
+	public function convert(LoggerLoggingEvent $event) {
+		$name = $event->getLocationInformation()->getClassName();
+	
+		if (!isset($this->cache[$name])) {
+	
+			// If length is set return shortened class name
+			if (isset($this->length)) {
+				$this->cache[$name] = LoggerUtils::shortenClassName($name, $this->length);
+			}
+				
+			// If no length is specified return the full class name
+			else {
+				$this->cache[$name] = $name;
+			}
+		}
+	
+		return $this->cache[$name];
+	}
+}
+ 
\ No newline at end of file
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterCookie.php b/libraries/log4php.debug/pattern/LoggerPatternConverterCookie.php
new file mode 100644
index 0000000000000000000000000000000000000000..592e66fe5c35d2bdfb3392a9c46368a439c15949
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterCookie.php
@@ -0,0 +1,35 @@
+<?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 $_COOKIE superglobal array corresponding to the 
+ * given key. If no key is given, return all values.
+ * 
+ * Options:
+ *  [0] $_COOKIE key value
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterCookie extends LoggerPatternConverterSuperglobal {
+	protected $name = '_COOKIE';
+}
\ No newline at end of file
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterDate.php b/libraries/log4php.debug/pattern/LoggerPatternConverterDate.php
new file mode 100644
index 0000000000000000000000000000000000000000..d3e9cb5173cbb3bdda99e280aa5b58436acb407f
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterDate.php
@@ -0,0 +1,91 @@
+<?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 date/time of the logging request.
+ * 
+ * Option: the datetime format, as used by the date() function. If 
+ * the option is not given, the default format 'c' will be used.
+ * 
+ * There are several "special" values which can be given for this option:
+ * 'ISO8601', 'ABSOLUTE' and 'DATE'.
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterDate extends LoggerPatternConverter {
+
+	const DATE_FORMAT_ISO8601 = 'c';
+	
+	const DATE_FORMAT_ABSOLUTE = 'H:i:s';
+	
+	const DATE_FORMAT_DATE = 'd M Y H:i:s.u';
+	
+	private $format = self::DATE_FORMAT_ISO8601;
+	
+	private $specials = array(
+		'ISO8601' => self::DATE_FORMAT_ISO8601,
+		'ABSOLUTE' => self::DATE_FORMAT_ABSOLUTE,
+		'DATE' => self::DATE_FORMAT_DATE,
+	);
+	
+	private $useLocalDate = false;
+	
+	public function activateOptions() {
+		
+		// Parse the option (date format)
+		if (!empty($this->option)) {
+			if(isset($this->specials[$this->option])) {
+				$this->format = $this->specials[$this->option];
+			} else {
+				$this->format = $this->option;
+			}
+		}
+		
+		// Check whether the pattern contains milliseconds (u)
+		if (preg_match('/(?<!\\\\)u/', $this->format)) {
+			$this->useLocalDate = true;
+		}
+	}
+	
+	public function convert(LoggerLoggingEvent $event) {
+		if ($this->useLocalDate) {
+			return $this->date($this->format, $event->getTimeStamp());
+		}
+		return date($this->format, $event->getTimeStamp());
+	}
+	
+	/**
+	 * Currently, PHP date() function always returns zeros for milliseconds (u)
+	 * on Windows. This is a replacement function for date() which correctly 
+	 * displays milliseconds on all platforms. 
+	 * 
+	 * It is slower than PHP date() so it should only be used if necessary. 
+	 */
+	private function date($format, $utimestamp) {
+		$timestamp = floor($utimestamp);
+		$ms = floor(($utimestamp - $timestamp) * 1000);
+		$ms = str_pad($ms, 3, '0', STR_PAD_LEFT);
+	
+		return date(preg_replace('`(?<!\\\\)u`', $ms, $format), $timestamp);
+	}
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterEnvironment.php b/libraries/log4php.debug/pattern/LoggerPatternConverterEnvironment.php
new file mode 100644
index 0000000000000000000000000000000000000000..b4bebd3c5533b7811ec755d1e44a652baa9708fe
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterEnvironment.php
@@ -0,0 +1,35 @@
+<?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 $_ENV superglobal array corresponding to the 
+ * given key.
+ * 
+ * Options:
+ *  [0] $_ENV key value
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterEnvironment extends LoggerPatternConverterSuperglobal {
+	protected $name = '_ENV';
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterFile.php b/libraries/log4php.debug/pattern/LoggerPatternConverterFile.php
new file mode 100644
index 0000000000000000000000000000000000000000..977191fb47a3e7211d0d03ae89858c699d8676b4
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterFile.php
@@ -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 name of the file from which the logging request was issued. 
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterFile extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return $event->getLocationInformation()->getFileName();
+	}
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterLevel.php b/libraries/log4php.debug/pattern/LoggerPatternConverterLevel.php
new file mode 100644
index 0000000000000000000000000000000000000000..6150e86ba5bfea30e05bb71fe5a33b3a0b12d7f0
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterLevel.php
@@ -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 event's level.
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterLevel extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return $event->getLevel()->toString();
+	}
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterLine.php b/libraries/log4php.debug/pattern/LoggerPatternConverterLine.php
new file mode 100644
index 0000000000000000000000000000000000000000..c5d74504265095435f0391966ac3e635341905ee
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterLine.php
@@ -0,0 +1,35 @@
+<?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 line number within the file from which the logging request was 
+ * issued. 
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterLine extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return $event->getLocationInformation()->getLineNumber();
+	}
+}
diff --git a/libraries/log4php.debug/helpers/LoggerClassNamePatternConverter.php b/libraries/log4php.debug/pattern/LoggerPatternConverterLiteral.php
similarity index 64%
rename from libraries/log4php.debug/helpers/LoggerClassNamePatternConverter.php
rename to libraries/log4php.debug/pattern/LoggerPatternConverterLiteral.php
index 88e2cd86c95b3909cce33a4a451cf1186d9db1a0..a907dbfa0434b002af99eb729e8766665151bfc7 100644
--- a/libraries/log4php.debug/helpers/LoggerClassNamePatternConverter.php
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterLiteral.php
@@ -1,45 +1,40 @@
-<?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
- */
-
-/**
- * @package log4php
- * @subpackage helpers
- */
-class LoggerClassNamePatternConverter extends LoggerNamedPatternConverter {
-
-	/**
-	 * Constructor
-	 *
-	 * @param string $formattingInfo
-	 * @param integer $precision
-	 */
-	public function __construct($formattingInfo, $precision) {
-		parent::__construct($formattingInfo, $precision);
-	}
-
-	/**
-	 * @param LoggerLoggingEvent $event
-	 * @return string
-	 */
-	public function getFullyQualifiedName($event) {
-		return $event->getFullQualifiedClassname();
-	}
-}
-
+<?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 literal value passed in the constructor, without modifications.
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterLiteral extends LoggerPatternConverter {
+
+	private $literalValue;
+	
+	public function __construct($literalValue) {
+		$this->literalValue = $literalValue;
+	}
+	
+	public function convert(LoggerLoggingEvent $event) {
+		return $this->literalValue;
+	}
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterLocation.php b/libraries/log4php.debug/pattern/LoggerPatternConverterLocation.php
new file mode 100644
index 0000000000000000000000000000000000000000..5c4f3cf2f1769b8e84c5c8adba4c57d98ba4641c
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterLocation.php
@@ -0,0 +1,39 @@
+<?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 line number within the file from which the logging request was 
+ * issued. 
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterLocation extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return 
+			$event->getLocationInformation()->getClassName() . '.' .
+			$event->getLocationInformation()->getMethodName() . '(' .
+			$event->getLocationInformation()->getFileName() . ':' .
+			$event->getLocationInformation()->getLineNumber() . ')';
+	}
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterLogger.php b/libraries/log4php.debug/pattern/LoggerPatternConverterLogger.php
new file mode 100644
index 0000000000000000000000000000000000000000..12ec729e6c2bfca185f7667e0ad0f1d7f04cad7e
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterLogger.php
@@ -0,0 +1,65 @@
+<?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 logger which created the logging request.
+ * 
+ * Takes one option, which is an integer. If the option is given, the logger 
+ * name will be shortened to the given length, if possible.
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterLogger extends LoggerPatternConverter {
+
+	/** Length to which to shorten the name. */
+	private $length;
+	
+	/** Holds processed logger names. */
+	private $cache = array();
+	
+	public function activateOptions() {
+		// Parse the option (desired output length)
+		if (isset($this->option) && is_numeric($this->option) && $this->option >= 0) {
+			$this->length = (integer) $this->option;
+		}
+	}
+	
+	public function convert(LoggerLoggingEvent $event) {
+		$name = $event->getLoggerName();
+		
+		if (!isset($this->cache[$name])) {
+
+			// If length is set return shortened logger name 
+			if (isset($this->length)) {
+				$this->cache[$name] = LoggerUtils::shortenClassName($name, $this->length);
+			} 
+			
+			// If no length is specified return full logger name
+			else {
+				$this->cache[$name] = $name;
+			}
+		} 
+		
+		return $this->cache[$name];
+	}
+}
diff --git a/libraries/log4php.debug/helpers/LoggerDatePatternConverter.php b/libraries/log4php.debug/pattern/LoggerPatternConverterMDC.php
similarity index 54%
rename from libraries/log4php.debug/helpers/LoggerDatePatternConverter.php
rename to libraries/log4php.debug/pattern/LoggerPatternConverterMDC.php
index fcbc440c2e82c6a56722d571c1b2cf7756658a83..5139f3d9ee94128efd65357632299030f5b85b06 100644
--- a/libraries/log4php.debug/helpers/LoggerDatePatternConverter.php
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterMDC.php
@@ -1,53 +1,55 @@
-<?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
- */
-
-/**
- * @package log4php
- * @subpackage helpers
- */
-class LoggerDatePatternConverter extends LoggerPatternConverter {
-
-	/**
-	 * @var string
-	 */
-	private $df;
-	
-	/**
-	 * Constructor
-	 *
-	 * @param string $formattingInfo
-	 * @param string $df
-	 */
-	public function __construct($formattingInfo, $df) {
-		parent::__construct($formattingInfo);
-		$this->df = $df;
-	}
-
-	/**
-	 * @param LoggerLoggingEvent $event
-	 * @return string
-	 */
-	public function convert($event) {
-		$timeStamp = $event->getTimeStamp();
-		$usecs = round(($timeStamp - (int)$timeStamp) * 1000);
-		$df = preg_replace('/((?<!\\\\)(?:\\\\{2})*)u/', '${1}' . sprintf('%03d', $usecs), $this->df);
-		return date($df, $timeStamp);
-	}
-}
+<?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 Mapped Diagnostic Context value corresponding to the given key.
+ * 
+ * Options:
+ *  [0] the MDC key
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterMDC extends LoggerPatternConverter {
+
+	private $key;
+
+	public function activateOptions() {
+		if (isset($this->option) && $this->option !== '') {
+			$this->key = $this->option;
+		}
+	}
+	
+	public function convert(LoggerLoggingEvent $event) {
+		if (isset($this->key)) {
+			return $event->getMDC($this->key);
+		} else {
+			$buff = array();
+			$map = $event->getMDCMap();
+			foreach($map as $key => $value) {
+				$buff []= "$key=$value";
+			}
+			return implode(', ', $buff);
+		}
+	}
+}
+ 
\ No newline at end of file
diff --git a/libraries/log4php.debug/helpers/LoggerLiteralPatternConverter.php b/libraries/log4php.debug/pattern/LoggerPatternConverterMessage.php
similarity index 62%
rename from libraries/log4php.debug/helpers/LoggerLiteralPatternConverter.php
rename to libraries/log4php.debug/pattern/LoggerPatternConverterMessage.php
index 737af8550f99f4089b8c09bec120e01f8fb1adc6..21b88e059f94380d641f2bc571f34095bc5445d1 100644
--- a/libraries/log4php.debug/helpers/LoggerLiteralPatternConverter.php
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterMessage.php
@@ -1,57 +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
- */
-
-/**
- * @package log4php
- * @subpackage helpers
- */
-class LoggerLiteralPatternConverter extends LoggerPatternConverter {
-	
-	/**
-	 * @var string
-	 */
-	private $literal;
-
-	/**
-	 * Constructor
-	 *
-	 * @param string $value
-	 */
-	public function __construct($value) {
-		$this->literal = $value;
-	}
-
-	/**
-	 * @param string &$sbuf
-	 * @param LoggerLoggingEvent $event
-	 */
-	public function format(&$sbuf, $event) {
-		$sbuf .= $this->literal;
-	}
-
-	/**
-	 * @param LoggerLoggingEvent $event
-	 * @return string
-	 */
-	public function convert($event) {
-		return $this->literal;
-	}
-}
-
+<?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
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterMessage extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return $event->getRenderedMessage();
+	}
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterMethod.php b/libraries/log4php.debug/pattern/LoggerPatternConverterMethod.php
new file mode 100644
index 0000000000000000000000000000000000000000..71241b9ad90830b65d343e8eab6302f6f962ccd7
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterMethod.php
@@ -0,0 +1,35 @@
+<?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
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterMethod extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return $event->getLocationInformation()->getMethodName();
+	}
+}
diff --git a/libraries/log4php.debug/helpers/LoggerMDCPatternConverter.php b/libraries/log4php.debug/pattern/LoggerPatternConverterNDC.php
similarity index 64%
rename from libraries/log4php.debug/helpers/LoggerMDCPatternConverter.php
rename to libraries/log4php.debug/pattern/LoggerPatternConverterNDC.php
index 8c835ace37667b378a76b4b609d58bf965291751..75be4183444243f475d10df68940c78485161536 100644
--- a/libraries/log4php.debug/helpers/LoggerMDCPatternConverter.php
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterNDC.php
@@ -1,50 +1,35 @@
-<?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
- */
-
-/**
- * @package log4php
- * @subpackage helpers
- */
-class LoggerMDCPatternConverter extends LoggerPatternConverter {
-
-	/**
-	 * @var string
-	 */
-	private $key;
-
-	/**
-	 * Constructor
-	 *
-	 * @param string $formattingInfo
-	 * @param string $key
-	 */
-	public function __construct($formattingInfo, $key) {
-		parent::__construct($formattingInfo);
-		$this->key = $key;
-	}
-
-	/**
-	 * @param LoggerLoggingEvent $event
-	 * @return string
-	 */
-	public function convert($event) {
-		return $event->getMDC($this->key);
-	}
-}
+<?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
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterNDC extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return $event->getNDC();
+	}
+}
+ 
\ No newline at end of file
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterNewLine.php b/libraries/log4php.debug/pattern/LoggerPatternConverterNewLine.php
new file mode 100644
index 0000000000000000000000000000000000000000..eecfc2b20778c408d5c573745105cf9e14786b19
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterNewLine.php
@@ -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 platform-specific newline character(s). 
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterNewLine extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return PHP_EOL;
+	}
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterProcess.php b/libraries/log4php.debug/pattern/LoggerPatternConverterProcess.php
new file mode 100644
index 0000000000000000000000000000000000000000..6a005d8958f97442772742126d33e4d8c9d9022f
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterProcess.php
@@ -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 PID of the current process.
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterProcess extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		return getmypid();
+	}
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterRelative.php b/libraries/log4php.debug/pattern/LoggerPatternConverterRelative.php
new file mode 100644
index 0000000000000000000000000000000000000000..f053dbecb68f4c924cde6aadb018b5d760a4f861
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterRelative.php
@@ -0,0 +1,36 @@
+<?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
+ * @version $Revision: 1379731 $
+ * @since 2.3
+ */
+class LoggerPatternConverterRelative extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		$ts = $event->getRelativeTime();
+		return number_format($ts, 4);
+	}
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterRequest.php b/libraries/log4php.debug/pattern/LoggerPatternConverterRequest.php
new file mode 100644
index 0000000000000000000000000000000000000000..0819f871ac7baaa7b71d40a09bdde97b9c9b4e4a
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterRequest.php
@@ -0,0 +1,35 @@
+<?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
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterRequest extends LoggerPatternConverterSuperglobal {
+	protected $name = '_REQUEST';
+}
\ No newline at end of file
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterServer.php b/libraries/log4php.debug/pattern/LoggerPatternConverterServer.php
new file mode 100644
index 0000000000000000000000000000000000000000..5e2a128d7f91d3337cc03971d190f99ae04944e9
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterServer.php
@@ -0,0 +1,35 @@
+<?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
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterServer extends LoggerPatternConverterSuperglobal {
+	protected $name = '_SERVER';
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterSession.php b/libraries/log4php.debug/pattern/LoggerPatternConverterSession.php
new file mode 100644
index 0000000000000000000000000000000000000000..97d51baaa1cc8d4cf761e94b15d91e4b33b9a04f
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterSession.php
@@ -0,0 +1,35 @@
+<?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
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterSession extends LoggerPatternConverterSuperglobal {
+	protected $name = '_SESSION';
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterSessionID.php b/libraries/log4php.debug/pattern/LoggerPatternConverterSessionID.php
new file mode 100644
index 0000000000000000000000000000000000000000..7dce095168a76681ce3d17724860b29f5878a17c
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterSessionID.php
@@ -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 active session ID, or an empty string if out of session. 
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+class LoggerPatternConverterSessionID extends LoggerPatternConverter {
+	public function convert(LoggerLoggingEvent $event) {
+		return session_id();
+	}
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterSuperglobal.php b/libraries/log4php.debug/pattern/LoggerPatternConverterSuperglobal.php
new file mode 100644
index 0000000000000000000000000000000000000000..26f377ba6b70e11b8e382cc75dcc95d91874a9d2
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterSuperglobal.php
@@ -0,0 +1,102 @@
+<?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
+ * @version $Revision: 1326626 $
+ * @since 2.3
+ */
+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;
+	}
+}
diff --git a/libraries/log4php.debug/pattern/LoggerPatternConverterThrowable.php b/libraries/log4php.debug/pattern/LoggerPatternConverterThrowable.php
new file mode 100644
index 0000000000000000000000000000000000000000..e21804dfc450dde4fbe069393be7179297759c3e
--- /dev/null
+++ b/libraries/log4php.debug/pattern/LoggerPatternConverterThrowable.php
@@ -0,0 +1,40 @@
+<?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.
+ * 
+ * @package log4php
+ * @subpackage pattern
+ * @version $Revision: 1395470 $
+ * @since 2.3
+ */
+class LoggerPatternConverterThrowable extends LoggerPatternConverter {
+
+	public function convert(LoggerLoggingEvent $event) {
+		$info = $event->getThrowableInformation();
+		if (isset($info)) {
+			$ex = $info->getThrowable();
+			return (string) $ex . PHP_EOL;
+		}
+		return '';
+	}
+}
+ 
\ No newline at end of file
diff --git a/libraries/log4php.debug/helpers/LoggerCategoryPatternConverter.php b/libraries/log4php.debug/renderers/LoggerRenderer.php
similarity index 65%
rename from libraries/log4php.debug/helpers/LoggerCategoryPatternConverter.php
rename to libraries/log4php.debug/renderers/LoggerRenderer.php
index 45f77f859fe2e9aa0b7cf23cdd86c714c5d74100..70611bd22e604af4385c7b955792b8225dabdbf0 100644
--- a/libraries/log4php.debug/helpers/LoggerCategoryPatternConverter.php
+++ b/libraries/log4php.debug/renderers/LoggerRenderer.php
@@ -19,26 +19,18 @@
  */
 
 /**
+ * Implement this interface in order to render objects to strings.
+ *
+ * @version $Revision: 1394956 $
  * @package log4php
- * @subpackage helpers
+ * @subpackage renderers
+ * @since 0.3
  */
-class LoggerCategoryPatternConverter extends LoggerNamedPatternConverter {
-
-	/**
-	 * Constructor
-	 *
-	 * @param string $formattingInfo
-	 * @param integer $precision
-	 */
-	public function __construct($formattingInfo, $precision) {
-		parent::__construct($formattingInfo, $precision);
-	}
-
+interface LoggerRenderer {
 	/**
-	 * @param LoggerLoggingEvent $event
-	 * @return string
+	 * Renders the entity passed as <var>input</var> to a string.
+	 * @param mixed $input The entity to render.
+	 * @return string The rendered string.
 	 */
-	public function getFullyQualifiedName($event) {
-		return $event->getLoggerName();
-	}
+	public function render($input);
 }
diff --git a/libraries/log4php.debug/renderers/LoggerRendererDefault.php b/libraries/log4php.debug/renderers/LoggerRendererDefault.php
index 294fe6e6a0b30fdfd705c162bd93169ad2d7fdd9..2f35f97920faa14546f35cd4ec2764b0de0c1d3b 100644
--- a/libraries/log4php.debug/renderers/LoggerRendererDefault.php
+++ b/libraries/log4php.debug/renderers/LoggerRendererDefault.php
@@ -19,33 +19,18 @@
  */
 
 /**
- * The default Renderer renders objects by type casting.
+ * The default renderer, which is used when no other renderer is found.
  * 
- * Example:
- * 
- * {@example ../../examples/php/renderer_default.php 19}<br>
- * {@example ../../examples/resources/renderer_default.properties 18}<br>
- * <pre>
- * DEBUG - Now comes the current MyClass object:
- * DEBUG - Person::__set_state(array(
- *  'firstName' => 'John',
- *  'lastName' => 'Doe',
- * ))
- * </pre>
+ * Renders the input using <var>print_r</var>.
  *
  * @package log4php
  * @subpackage renderers
  * @since 0.3
  */
-class LoggerRendererDefault implements LoggerRendererObject {
+class LoggerRendererDefault implements LoggerRenderer {
 
-	/**
-	 * Render objects by type casting
-	 *
-	 * @param mixed $o the object to render
-	 * @return string
-	 */
-	public function render($o) {
-		return var_export($o, true);
+	/** @inheritdoc */
+	public function render($input) {
+		return print_r($input, true);
 	}
 }
diff --git a/libraries/log4php.debug/renderers/LoggerRendererException.php b/libraries/log4php.debug/renderers/LoggerRendererException.php
index f9134a9c42b81c175b70e734775a69b135448c75..d78bcb87901cf693b65a2674c8c2aaf66928f108 100644
--- a/libraries/log4php.debug/renderers/LoggerRendererException.php
+++ b/libraries/log4php.debug/renderers/LoggerRendererException.php
@@ -19,23 +19,18 @@
  */
 
 /**
- * Exception renderer
+ * Renderer used for Exceptions.
  *
  * @package log4php
  * @subpackage renderers
  * @since 2.1
  */
-class LoggerRendererException implements LoggerRendererObject {
+class LoggerRendererException implements LoggerRenderer {
 
-	public function render($o) {
-		$strRep  = 'Throwable('.get_class($o).'): '.$o->getMessage().' in '.$o->getFile().' on line '.$o->getLine();
-		$strRep .= PHP_EOL.$o->getTraceAsString();
+	public function render($input) {
 		
-		if (method_exists($o, 'getPrevious') && $o->getPrevious() !== null) {
-			$strRep .= PHP_EOL.'Caused by: '.$this->render($o->getPrevious());
-		}
-		
-		return $strRep;		
+		// Exception class has a very decent __toString method
+		// so let's just use that instead of writing lots of code.
+		return (string) $input; 
 	}
 }
-?>
\ No newline at end of file
diff --git a/libraries/log4php.debug/renderers/LoggerRendererMap.php b/libraries/log4php.debug/renderers/LoggerRendererMap.php
index 980503f4ce2c9a61ecced835aa08e9951539a690..c42f1ff0445cc6c4b02602f8ee6f83e856a3a364 100644
--- a/libraries/log4php.debug/renderers/LoggerRendererMap.php
+++ b/libraries/log4php.debug/renderers/LoggerRendererMap.php
@@ -19,17 +19,10 @@
  */
 
 /**
- * Log objects using customized renderers that implement {@link LoggerRendererObject}.
+ * Manages defined renderers and determines which renderer to use for a given 
+ * input. 
  *
- * Example:
- * {@example ../../examples/php/renderer_map.php 19}<br>
- * {@example ../../examples/resources/renderer_map.properties 18}<br>
- * <pre>
- * DEBUG - Now comes the current MyClass object:
- * DEBUG - Doe, John
- * </pre>
- * 
- * @version $Revision: 1166187 $
+ * @version $Revision: 1394956 $
  * @package log4php
  * @subpackage renderers
  * @since 0.3
@@ -37,113 +30,157 @@
 class LoggerRendererMap {
 
 	/**
+	 * Maps class names to appropriate renderers.
 	 * @var array
 	 */
-	private $map;
+	private $map = array();
 
 	/**
-	 * @var LoggerDefaultRenderer
+	 * The default renderer to use if no specific renderer is found. 
+	 * @var LoggerRenderer
 	 */
 	private $defaultRenderer;
-
-	/**
-	 * Constructor
-	 */
+	
 	public function __construct() {
-		$this->map = array();
-		$this->defaultRenderer = new LoggerRendererDefault();
+		
+		// Set default config
+		$this->reset();
 	}
 
 	/**
-	 * Add a renderer to a hierarchy passed as parameter.
-	 * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
+	 * Adds a renderer to the map.
+	 * 
+	 * If a renderer already exists for the given <var>$renderedClass</var> it 
+	 * will be overwritten without warning.
 	 *
-	 * @param LoggerHierarchy $repository a logger repository.
-	 * @param string $renderedClassName
-	 * @param string $renderingClassName
+	 * @param string $renderedClass The name of the class which will be 
+	 * 		rendered by the renderer.
+	 * @param string $renderingClass The name of the class which will 
+	 * 		perform the rendering.
 	 */
-	public function addRenderer($renderedClassName, $renderingClassName) {
-		$renderer = LoggerReflectionUtils::createObject($renderingClassName);
-		if($renderer == null) {
+	public function addRenderer($renderedClass, $renderingClass) {
+		// Check the rendering class exists
+		if (!class_exists($renderingClass)) {
+			trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] not found.");
+			return;
+		}
+		
+		// Create the instance
+		$renderer = new $renderingClass();
+		
+		// Check the class implements the right interface
+		if (!($renderer instanceof LoggerRenderer)) {
+			trigger_error("log4php: Failed adding renderer. Rendering class [$renderingClass] does not implement the LoggerRenderer interface.");
 			return;
-		} else {
-			$this->put($renderedClassName, $renderer);
 		}
+		
+		// Convert to lowercase since class names in PHP are not case sensitive
+		$renderedClass = strtolower($renderedClass);
+		
+		$this->map[$renderedClass] = $renderer;
 	}
-
-
+	
 	/**
-	 * Find the appropriate renderer for the class type of the
-	 * <var>o</var> parameter. 
+	 * Sets a custom default renderer class.
+	 * 
+	 * TODO: there's code duplication here. This method is almost identical to 
+	 * addRenderer(). However, it has custom error messages so let it sit for 
+	 * now.
 	 *
-	 * This is accomplished by calling the {@link getByObject()} 
-	 * method if <var>o</var> is object or using {@link LoggerRendererDefault}. 
-	 * Once a renderer is found, it is applied on the object <var>o</var> and 
-	 * the result is returned as a string.
+	 * @param string $renderingClass The name of the class which will 
+	 * 		perform the rendering.
+	 */
+	public function setDefaultRenderer($renderingClass) {
+		// Check the class exists
+		if (!class_exists($renderingClass)) {
+			trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] not found.");
+			return;
+		}
+		
+		// Create the instance
+		$renderer = new $renderingClass();
+		
+		// Check the class implements the right interface
+		if (!($renderer instanceof LoggerRenderer)) {
+			trigger_error("log4php: Failed setting default renderer. Rendering class [$renderingClass] does not implement the LoggerRenderer interface.");
+			return;
+		}
+		
+		$this->defaultRenderer = $renderer;
+	}
+	
+	/**
+	 * Returns the default renderer.
+	 * @var LoggerRenderer
+	 */
+	public function getDefaultRenderer() {
+		return $this->defaultRenderer;
+	}
+	
+	/**
+	 * Finds the appropriate renderer for the given <var>input</var>, and 
+	 * renders it (i.e. converts it to a string). 
 	 *
-	 * @param mixed $o
-	 * @return string 
+	 * @param mixed $input Input to render.
+	 * @return string The rendered contents.
 	 */
-	public function findAndRender($o) {
-		if($o == null) {
+	public function findAndRender($input) {
+		if ($input === null) {
 			return null;
-		} else {
-			if(is_object($o)) {
-				$renderer = $this->getByObject($o);
-				if($renderer !== null) {
-					return $renderer->render($o);
-				} else {
-					return null;
-				}
-			} else {
-				$renderer = $this->defaultRenderer;
-				return $renderer->render($o);
+		}
+		
+		// For objects, try to find a renderer in the map
+		if(is_object($input)) {
+			$renderer = $this->getByClassName(get_class($input));
+			if (isset($renderer)) {
+				return $renderer->render($input);
 			}
 		}
+		
+		// Fall back to the default renderer
+		return $this->defaultRenderer->render($input);
 	}
 
 	/**
-	 * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the
-	 * class of the object parameter.
+	 * Returns the appropriate renderer for a given object.
 	 * 
-	 * @param mixed $o
-	 * @return string
+	 * @param mixed $object
+	 * @return LoggerRenderer Or null if none found.
 	 */
-	public function getByObject($o) {
-		return ($o == null) ? null : $this->getByClassName(get_class($o));
+	public function getByObject($object) {
+		if (!is_object($object)) {
+			return null;
+		}
+		return $this->getByClassName(get_class($object));
 	}
-
-
+	
 	/**
-	 * Search the parents of <var>clazz</var> for a renderer. 
-	 *
-	 * The renderer closest in the hierarchy will be returned. If no
-	 * renderers could be found, then the default renderer is returned.
+	 * Returns the appropriate renderer for a given class name.
+	 * 
+	 * If no renderer could be found, returns NULL.
 	 *
 	 * @param string $class
-	 * @return LoggerRendererObject
+	 * @return LoggerRendererObject Or null if not found.
 	 */
 	public function getByClassName($class) {
-		$r = null;
-		for($c = $class; !empty($c); $c = get_parent_class($c)) {
-			$c = strtolower($c);
-			if(isset($this->map[$c])) {
-				return $this->map[$c];
+		for(; !empty($class); $class = get_parent_class($class)) {
+			$class = strtolower($class);
+			if(isset($this->map[$class])) {
+				return $this->map[$class];
 			}
 		}
-		return $this->defaultRenderer;
+		return null;
 	}
 
+	/** Empties the renderer map. */
 	public function clear() {
 		$this->map = array();
 	}
-
-	/**
-	 * Register a {@link LoggerRendererObject} for <var>clazz</var>.
-	 * @param string $class
-	 * @param LoggerRendererObject $or
-	 */
-	private function put($class, $or) {
-		$this->map[strtolower($class)] = $or;
+	
+	/** Resets the renderer map to it's default configuration. */
+	public function reset() {
+		$this->defaultRenderer = new LoggerRendererDefault();
+		$this->clear();
+		$this->addRenderer('Exception', 'LoggerRendererException');
 	}
 }
diff --git a/libraries/log4php.debug/renderers/LoggerRendererObject.php b/libraries/log4php.debug/renderers/LoggerRendererObject.php
deleted file mode 100644
index 3f0e39e9b55d401e0286da242c2481c1b9df639a..0000000000000000000000000000000000000000
--- a/libraries/log4php.debug/renderers/LoggerRendererObject.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?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
- */
-
-/**
- * Implement this interface in order to render objects as strings using {@link LoggerRendererMap}.
- *
- * Implement this interface in order to render objects as strings using {@link LoggerRendererMap}.
- *
- * Example:
- * {@example ../../examples/php/renderer_map.php 19}<br>
- * {@example ../../examples/resources/renderer_map.properties 18}<br>
- * <pre>
- * DEBUG - Now comes the current MyClass object:
- * DEBUG - Doe, John
- * </pre>
- *
- * @version $Revision: 883108 $
- * @package log4php
- * @subpackage renderers
- * @since 0.3
- */
-interface LoggerRendererObject {
-	/**
-	 * Render the entity passed as parameter as a String.
-	 * @param mixed $o entity to render
-	 * @return string
-	 */
-	public function render($o);
-}
diff --git a/libraries/log4php.debug/tutorials/log4php/log4php.pkg b/libraries/log4php.debug/tutorials/log4php/log4php.pkg
deleted file mode 100644
index 729b5d1243e2009d5c32da385915da280339368c..0000000000000000000000000000000000000000
--- a/libraries/log4php.debug/tutorials/log4php/log4php.pkg
+++ /dev/null
@@ -1,28 +0,0 @@
-<refentry id="{@id}">
-
-  <refnamediv>
-    <refname>Apache log4php</refname>                                                                                                                                                                                                                                                              
-   </refnamediv>  
- 
-  <refsect1 id="{@id license}">
-    <para>
-        <![CDATA[
-  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.
-       ]]>
-    </para>
- </refsect1>
- 
-</refentry>