I have a strange issue. Almost definitely I am doing something stupid, but I can’t figure out where the stupid is.
So in my debug.log, I am getting double entries, like so:
a
b
c
a
b
c
But it seems like it’s related to whatever process/call is being run. For example, I may have a double entry when an AJAX call fully completes, with a start like:
2022-11-19 18:29:07 [127.0.0.1][106][-][trace][yii\base\Application::bootstrap] Bootstrap with mootensai\enhancedgii\Bootstrap::bootstrap()
2022-11-19 18:29:07 [127.0.0.1][106][-][trace][yii\base\Module::getModule] Loading module: gii
2022-11-19 18:29:07 [127.0.0.1][106][-][trace][yii\base\Application::bootstrap] Bootstrap with yii\shell\Bootstrap::bootstrap()
2022-11-19 18:29:07 [127.0.0.1][106][-][trace][yii\base\Application::bootstrap] Bootstrap with omnilight\scheduling\Bootstrap::bootstrap()
2022-11-19 18:29:07 [127.0.0.1][106][-][trace][yii\base\Application::bootstrap] Bootstrap with yii\queue\db\Queue::bootstrap()
2022-11-19 18:29:07 [127.0.0.1][106][-][trace][yii\base\Application::bootstrap] Bootstrap with yii\queue\db\Queue::bootstrap()
2022-11-19 18:29:07 [127.0.0.1][106][-][trace][yii\base\Application::bootstrap] Bootstrap with silverslice\queueFailed\QueueFailed::bootstrap()
2022-11-19 18:29:07 [127.0.0.1][106][-][trace][yii\base\Application::bootstrap] Bootstrap with justcoded\yii2\eventlistener\components\EventListener::bootstrap()
2022-11-19 18:29:07 [127.0.0.1][106][-][trace][yii\base\Application::bootstrap] Bootstrap with yii\log\Dispatcher
2022-11-19 18:29:07 [127.0.0.1][106][-][trace][yii\base\Application::bootstrap] Bootstrap with brussens\maintenance\Maintenance::bootstrap()
to where the AJAX call returns the data.
For clarity, it is NOT like this:
a
a
b
b
c
c
I have scanned my configuration several times and can’t figure out what is causing this. Below is my logging configuration. Any help is appreciated!
<?php
$config['components']['log']['tracelevel'] = YII_DEBUG ? 3 : 0;
$config['components']['log']['flushInterval'] = YII_DEBUG ? 1 : 1000;
/**
* be sure to add any env vars here that should be masked, e.g., API keys,
* passwords, etc., usually found in $HOME/.env
*/
$loggerMaskVars = [
'_SERVER.HTTP_AUTHORIZATION',
'_SERVER.PHP_AUTH_USER',
'_SERVER.PHP_AUTH_PW',
'_SERVER.DB_USER',
'_SERVER.DB_PASS',
'_SERVER.EMAIL_USERNAME',
'_SERVER.EMAIL_PASSWORD',
];
$config['components']['log']['targets'][] = [
'class' => 'yii\log\FileTarget',
'categories' => ['yii\swiftmailer\Logger::add'],
'enabled' => YII_DEBUG,
'enableRotation' => true,
'logFile' => '@runtime/logs/mailer.log',
'logVars' => [], // don't include ENV vars
'maskVars' => $loggerMaskVars,
];
// perf profiling
$config['components']['log']['targets'][] = [
'class' => 'yii\log\FileTarget',
'enabled' => $isProfilingEnabled,
'levels' => ['profile'],
'except' => ['yii\base\Application:bootstrap', 'yii\db\*', 'yii\web\*', 'yii\queue\*'],
'enableRotation' => true,
'logFile' => '@runtime/logs/profile.log',
'logVars' => [], // don't include ENV vars
'maskVars' => $loggerMaskVars,
];
// these are picked up by newrelic!
$config['components']['log']['targets'][] = [
'class' => 'yii\log\FileTarget',
'enabled' => true,
'levels' => ['error', 'warning'],
'enableRotation' => true,
'except' => ['apicall', 'yii\web\HttpException:404'],
'logFile' => '@runtime/logs/errors.log',
'logVars' => [], // don't include ENV vars
'maskVars' => $loggerMaskVars,
];
$config['components']['log']['targets'][] = [
'class' => 'yii\log\FileTarget',
'enabled' => true,
'enableRotation' => true,
'maxLogFiles' => 20,
'categories' => ['apicall'],
'logFile' => '@common/logs/apicalls.log',
'logVars' => [], // don't include ENV vars
'maskVars' => $loggerMaskVars,
];
// include env vars in this one -- used when debugging but doesn't
// go to Newrelic, etc.
$config['components']['log']['targets'][] = [
'class' => 'yii\log\FileTarget',
'enabled' => true,
'levels' => ['error', 'warning'],
'enableRotation' => true,
'except' => ['apicall', 'yii\web\HttpException:404', 'yii\base\View::renderFile'],
'logFile' => '@runtime/logs/errors-full.log',
//'logVars' => [], // don't include ENV vars
'maskVars' => $loggerMaskVars,
];
$config['components']['log']['targets'][] = [
'class' => 'yii\log\FileTarget',
'enabled' => true,
'enableRotation' => true,
'categories' => ['yii\web\HttpException:404'],
'logFile' => '@runtime/logs/404.log',
'logVars' => [], // don't include ENV vars
'maskVars' => $loggerMaskVars,
];
$config['components']['log']['targets'][] = [
'class' => 'yii\log\FileTarget',
'enabled' => true,
'enableRotation' => true,
'except' => [
'apicall',
'yii\web\HttpException:404',
'yii\db\*',
'yii\web\UrlManager::parseRequest',
'yii\httpclient\*',
'yii\base\View::renderFile',
],
'logFile' => '@runtime/logs/debug.log',
'logVars' => [], // don't include ENV vars
'maskVars' => $loggerMaskVars,
];
$config['components']['log']['targets'][] = [
'class' => 'yii\log\DbTarget',
'enabled' => true,
'levels' => ['info'],
'except' => ['apicall', 'yii\base\Application:bootstrap', 'yii\db\*', 'yii\web\*', 'yii\queue\*', 'application'],
'maskVars' => $loggerMaskVars,
];