override log4php

<?php

/**
* Log util for log4php
* @see Logger
* @author jake
* @since 2012-01-19
**/
if (! class_exists ( "EdLoggerConfigurator" )) {
### Insert the path where you unpacked log4php ###
include_once PATH_PLUGINS . 'edautomate' . PATH_SEP . 'classes' . PATH_SEP . 'log4php' . PATH_SEP . 'Logger.php';

class EdLoggerConfigurator implements LoggerConfigurator {

public function configure(LoggerHierarchy $hierarchy, $input = null) {

$appender = new LoggerAppenderRollingFile ( SYS_SYS . "Appender" );
$appender->setFile ( PATH_DATA_SITE . PATH_SEP . 'jake.log', true );
$appender->setMaxBackupIndex ( 10 );
$appender->setMaxFileSize ( "10MB" );
$appenderlayout = new LoggerLayoutPattern ();
$pattern = '%d{ISO8601} [%p] %c: %m (at %F line %L)%n';
$appenderlayout->setConversionPattern ( $pattern );
$appender->setLayout ( $appenderlayout );
$appender->activateOptions ();
// Add both appenders to the root logger
$root = $hierarchy->getRootLogger ();
$root->addAppender ( $appender );
return $root;
}
}
}
?>

posted @ 2012-01-19 14:14  Jake.Xu  阅读(...)  评论(... 编辑 收藏