kpleines
(Kp News)
1
I’ve tried to enable logging into two diffrent files by using this configuration:
'log' => [
#'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => [ 'error', 'warning','trace'],
'maxFileSize' => 1024 * 2,
'maxLogFiles' => 20,
],
[
'class' => 'yii\log\FileTarget',
'categories' => ['protokoll'],
'levels' =>['info'],
'logFile' => '@app/runtime/logs/protokoll.log',
'maxFileSize' => 1024 * 2,
'maxLogFiles' => 20,
],
],
],
The problem is, that all logs are logged into the "protokoll.log" logfile not only my special logs using:
\Yii::info('EMail versendet für >'.$user->name.'<', 'protokoll');
Can somebody help me what’s the problem is?
Bizley
(Bizley)
2
Are you sure all logs go to protokoll.log and not all categories including ‘protokoll’ go to default log?
Add
'except' => ['protokoll'],
to first target.
kpleines
(Kp News)
3
Thank you for reply.
Each time I call the Controller the "protokoll" log entry will be logget in to runtime/protokoll.log
and also the follonwing session Infos will be logged :
2015-11-18 18:38:36 [192.168.178.140][100][-][info][protokoll] sendWeeklyReminder
2015-11-18 18:38:36 [192.168.178.140][100][-][info][application] $_GET = [
'r' => 'site/index'
]
$_COOKIE = [
'_ga' => 'GA1.2.927439308.1438667412'
'_octo' => 'GH1.1.1100753071.1438434582'
'_csrf' => '990c52949dbe2840b38c7d236139b6b8fecc257c3cbab40eb79c9cc2c42fc36ba:2:{i:0;s:5:\"_csrf\";i:1;s:32:\"fa4j95SyjSXy_gRoQMVzFyW3-gb2dhKZ\";}'
'PHPSESSID' => 'sscd00rptfhs1tg9ebbf7ncnl2'
'_identity' => '10f7a70999a71a66b720d42b5b0985d387bca59bcf8e55e2f7a5e830f29af402a:2:{i:0;s:9:\"_identity\";i:1;s:28:\"[\"100\",\"test100key\",2592000]\";}'
'pma_navi_width' => '200'
]
$_SESSION = [
'__flash' => []
'__id' => '100'
]
$_SERVER = [
'HTTP_HOST' => 'lanvmwareqnapy.fritz.box'
'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0'
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
I’ve tried to find the log statement for the session logs with no success.
Bizley
(Bizley)
4
kpleines
(Kp News)
5
I finally solved my problem:
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
[
'class' => 'yii\log\FileTarget',
'levels' => ['info'],
'categories' => ['abc'],
'logVars' => [null],
'logFile' => '@app/runtime/logs/abc/abc.log',
'maxFileSize' => 1024 * 2,
'maxLogFiles' => 20,
],
],
],
logVars is the key: ‘logVars’ => [null],