cms
cms copied to clipboard
[4.x]: console command logs below warning are never logged
What happened?
Description
Logging in console commands with level below warning is never logged. For some reason it was actively disabled, but now it can't be configured with log level anymore. This is confusing at least and doens't make much sense in my opinion.
Steps to reproduce
- Place a logging info statement inside a migration or other console command
Craft::info('some information about the migration', 'Migration');
- Set logging config to log info level My app.php configures:
'components' => [
'log' => [
'monologTargetConfig' => [
'logContext' => false,
'level' => App::devMode() ? LogLevel::INFO : LogLevel::WARNING
],
],
],
Expected behavior
Log is shown
Actual behavior
Log doesn't show up. The class MonologTarget:191 does not add a StreamHandler with correct logLevel incase the request is a console request. See:
$logger->pushHandler((new StreamHandler(
'php://stderr',
Logger::WARNING,
bubble: false,
))->setFormatter($this->formatter));
// Don't pollute console request output
if (!Craft::$app->getRequest()->getIsConsoleRequest()) { // <-- Why?
$logger->pushHandler((new StreamHandler(
'php://stdout',
$this->level,
bubble: false,
))->setFormatter($this->formatter));
}
Craft CMS version
Craft Pro 4.5.11.1
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
"codemix/yii2-streamlog": "1.3.1", "codemonauts/craft-readonly-field": "2.0.1", "craftcms/cms": "4.5.11.1", "craftcms/element-api": "^3.0.1.1", "craftcms/google-cloud": "^2.0.0", "craftcms/redactor": "^3.0.4", "dompdf/dompdf": "^2.0.3", "doublesecretagency/craft-cpcss": "2.6.0", "ether/tags": "2.0.0", "firebase/php-jwt": "5.2.0", "google/cloud-firestore": "^1.28", "kreait/firebase-php": "5.26.3", "mailjet/mailjet-apiv3-php": "^1.5", "postfinancecheckout/sdk": "^3.0", "promphp/prometheus_client_php": "^2.2", "vlucas/phpdotenv": "^5.4.0"