0
我是log4php的新手,我想動態更改日誌文件名和路徑。如何在log4php中動態更改日誌文件名?
我這樣做,但Test.log消息中沒有任何內容。
$crawlupLogger = Logger::getRootLogger();
$crawlupLogger->setLevel(LoggerLevel::toLevel(LoggerLevel::DEBUG));
$appender = new LoggerAppenderFile("MyAppender");
$appender->setFile("Test.log");
$appender->setAppend(false);
$appenderlayout = new LoggerLayoutPattern();
$pattern = '%date{U}%message%newline';
$appenderlayout->setConversionPattern($pattern);
$appender->setLayout($appenderlayout);
$appender->activateOptions();
$crawlupLogger->removeAllAppenders();
$crawlupLogger->addAppender($appender);
// Line head
$crawlupLogger->info("Date,Time,Level,Message");