Hi, i’m working on generating a logging file in my project, so i’ve read a bit about logging in Yii2 here.
Everything works really good. Currently i’m writing on a file named “general_log.log”, so i’ve configured my logger component like this:
<? ...
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'logVars' => [],
'levels' => ['error', 'warning'],
'categories' => ['general_log'],
'logFile' => '@app/runtime/logs/general_log.log',
],
],
],
...
?>
Then i add every message i want with:
<?php \Yii::info('My_Custom_Message', 'general_log'); ?>
The message gets added as expected. But there’s a couple of things i don’t know how to approach yet. How can i modify the message structure that gets added every time? right now the message looks like this:
2017-11-27 21:18:42 [::1][7][-][info][general_log] My_Custom_Message
in C:\xampp\htdocs\qaintranet\backend\views\site\start.php:52
in C:\xampp\htdocs\qaintranet\backend\controllers\SiteController.php:93
I would like to delete everything after "My_Custom_Message", is that possible?
Any help is appreciated, thanks.
EDIT: Nevermind, it was clearly stated in the docs. I didn’t read about “trace level”, so if anyone is wondering the same, just change ‘traceLevel’ => YII_DEBUG ? 3 : 0 to 'traceLevel => 0.
There’s another thing i would like to do with the logs, is there a way to add an empty space between each message? I have not been able to do it for now. Thanks again.
EDIT 2: Nevermind again, i was using notepad to view the file, if i use notepad++ or some other text editor every line gets added after the other. I’m really sorry, this post can be closed.