Hi, I have created a command, that calls another class that is used also in the web app (working fine), but when it is used from the command, throws this error:
Exception: Could not load class debug
#0 /var/app/current/vendor/cakephp/cakephp/src/Core/ObjectRegistry.php(95): Cake\Log\LogEngineRegistry->_throwMissingClassError('debug', NULL)
#1 /var/app/current/vendor/cakephp/cakephp/src/Log/Log.php(198): Cake\Core\ObjectRegistry->load('debug', Array)
#2 /var/app/current/vendor/cakephp/cakephp/src/Log/Log.php(180): Cake\Log\Log::_loadConfig()
#3 /var/app/current/vendor/cakephp/cakephp/src/Log/Log.php(351): Cake\Log\Log::_init()
#4 /var/app/current/vendor/cakephp/cakephp/src/Log/Log.php(501): Cake\Log\Log::write('debug', 'Executing query...', Array)
#5 /var/app/current/src/SearchUtils.php(88): Cake\Log\Log::debug('Executing query...', Array)
#6 /var/app/current/src/Model/Table/GcloudComputeInstancesTable.php(118): App\SearchUtils::searchCommand(Object(Cake\ORM\Query), Object(App\Model\Entity\User), NULL)
#7 /var/app/current/src/Command/GenerateSendReportEmailCommand.php(155): App\Model\Table\GcloudComputeInstancesTable->searchCommand(Object(App\Model\Entity\User), NULL)
#8 /var/app/current/vendor/cakephp/cakephp/src/Console/Command.php(183): App\Command\GenerateSendReportEmailCommand->execute(Object(Cake\Console\Arguments), Object(Cake\Console\ConsoleIo))
#9 /var/app/current/vendor/cakephp/cakephp/src/Console/CommandRunner.php(167): Cake\Console\Command->run(Array, Object(Cake\Console\ConsoleIo))
#10 /var/app/current/bin/cake.php(12): Cake\Console\CommandRunner->run(Array)
#11 {main}
This is my Log configuration in app.php
:
$debug = filter_var(env('CAKEPHP_DEBUG', false), FILTER_VALIDATE_BOOLEAN);
$log = [
'error' => [
'className' => 'Cake\Log\Engine\FileLog',
'path' => LOGS,
'file' => 'error',
'url' => env('LOG_ERROR_URL', null),
'scopes' => false,
'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
],
'sqllog' => [
'className' => 'Cake\Log\Engine\FileLog',
'path' => LOGS,
'file' => 'sqllog',
'scopes' => ['sqllog'],
],
];
if ($debug) {
$log['debug'] = [
'className' => 'Cake\Log\Engine\FileLog',
'path' => LOGS,
'file' => 'debug',
'url' => env('LOG_DEBUG_URL', null),
'scopes' => false,
'levels' => [],
];
}
// ....
return [
// ...
'Log' => $log,
// ...
];
Any idea? Thanks!