I always send logs on developer email for developers to look at exceptions that occurs in the system and fix the issue. However sometimes we need to know which user is experiencing the issue. With that, we need user ID. Have anyone have experience with this one? I cannot find a way to send it with log email.
Here is how I do it (sends logs but with no user identity details)
$config['components']['log'] = [
'traceLevel' => 3,
'targets' => [
[
'class' => 'yii\log\EmailTarget',
'mailer' => 'mailer',
'levels' => ['error', 'warning'],
'message' => [
'from' => ['someemail@example.com'],
'to' => ['problems@example.com'],
'subject' => Yii::t('app', 'Logs for {date} by {name} - {uid}', [
'date' => date('d-m-Y'),
'uid' => Yii::$app->user->id ?? 'NONE',
'name' => Yii::$app->user->identity->name ?? 'NONE',
]),
],
],
],
];
I get None for UID and Name
I will appreciate any idea