2011年3月27日 星期日

log4php - Change log file Name dynamically in log4php.properties

$rootlogger = Logger::getRootLogger();
$rootlogger->setLevel(LoggerLevel::toLevel(LoggerLevel::INFO));

$appender = new LoggerAppenderRollingFile("MyAppender");
$appender->setFile("custom_name.log", true);
$appender->setMaxBackupIndex(10);
$appender->setMaxFileSize("100MB");
$appenderlayout = new LoggerLayoutPattern();
$pattern = '%d{Y-m-d H:i:s} [%p] %c: %m (at %F line %L)%n';
$appenderlayout->setConversionPattern($pattern);
$appender->setLayout($appenderlayout);
$appender->activateOptions();

$rootlogger->removeAllAppenders();
$rootlogger->addAppender($appender);

$rootlogger->info("info");

reference : http://stackoverflow.com/questions/2658146/log4php-change-log-file-name-dynamically-in-log4php-properties

沒有留言:

wibiya widget