用于记录目的我正在使用以下代码
$logFile = __DIR__ . "/log/scheduler_logs\_log.txt";
print_r($logFile);
mkdir(dirname($logFile), "0777", true);
chmod("{$logFile}", 0777);
dirname($logFile) ? exec("($command) > $logFile") : exec("$command");
而不是这些我可以使用log4php..i试过一个简单的程序,但我不确定我可以在exec()内部使用。
`include_once "MyLogger.php";
$loggerinfo = LoggingInfo::getInstantLogger("myfolderpath");`
Mylogger.php
public static function getInstantLogger($path) {
Logger::configure(array(
'rootLogger' => array(
'appenders' => array('AppenderSkeleton'),
),
'appenders' => array(
'AppenderSkeleton' => array(
'class' => 'LoggerAppenderDailyFile',
'layout' => array(
'class' => 'LoggerLayoutPattern',
'params' => array(
'conversionPattern' => '%date [%logger] %message%newline'
)
),
'params' => array(
'file' => "./logs/$path/".gmdate('Y-m-d\Th:i:s'). '.log',
'append' => true,
'datePattern' => gmdate('Y-m-d')
)
)
)
));
return Logger::getRootLogger(); }