Hello,
I have a long running console script, that I need to monitor,
I want only this script to write to this log file (foo.log) and nothing else.
How can I set this up?
Thanks,
Urkman
Hello,
I have a long running console script, that I need to monitor,
I want only this script to write to this log file (foo.log) and nothing else.
How can I set this up?
Thanks,
Urkman
Give your log messages a category:
Yii::info($message, 'foo');
Then place a special class under your targets in the config file:
'log' => [
// ...
'targets' => [
[
'class' => 'yii\log\FileTarget',
// ...
],
// ...
[
'class' => 'yii\log\FileTarget',
'levels' => ['info'],
'categories' => ['foo'],
'logFile' => '@app/runtime/logs/foo.log',
],
Got the idea for a similar problem from here:
Best,
Joe
Hello PapaJoe,
thanks for your reply…
I already tried exactly that, but I always have the $SERVER data in my log file
Looks like this:
2015-03-16 09:25:01 [-][-][-][info][foo] test log...
2015-03-16 09:24:01 [-][-][-][info][application] $_SERVER = [ ... ]
I don’t want that “application” entry…
Any ideas?
Thanks,
Urkman
No one with an idea on how to get rid of this ‘application’ entries?
use yii\log\Target::$logVars property to determine which global variables you want to include by the log target. Here is how to disable all global variables:
'targets' => [
'class' => 'yii\log\FileTarget',
// some configurations
'logVars' => [],
],