2018年2月16日金曜日

cakephp 2.x 日付でログローテーション

Config/bootstrap.phpの「Configures default file logging options」を以下のようにすると良い
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
App::uses('CakeLog', 'Log');
$log_path = LOGS.DS.date('Ymd').DS;
$log_date = date('Ymd');
CakeLog::config('debug', array(
 'engine' => 'File',
 'types' => array('notice', 'info', 'debug'),
 // 'file' => 'debug',
 'file' => $log_date . '_debug.log',
));
CakeLog::config('error', array(
 'engine' => 'File',
 'types' => array('warning', 'error', 'critical', 'alert', 'emergency'),
 // 'file' => 'error',
 'file' => $log_date . '_error.log',
));