CakePHP 3 Custom Registration

I'm trying to set up a custom log file, but I don't understand the official documentation examples.

It describes how to use the FileLog adapter by specifying a stanza as shown below and placing it in your config / app.php file (however, the app.php file is not compatible with this format):

Log::config('custom_path', [
'className' => 'File',
'path' => '/path/to/custom/place/'
]);

      

And then, presumably, use that stanza in your class file like this:

$this->log("Something didn't work!", 'custom_path');

      

But then the message is written to the custom_path file containing the error

Invalid log level "custom_path"

      

Any help was appreciated.

+3


source to share


1 answer


try adding scopes to your log config. copy paste this:



Log::config('custom_path', [
'className' => 'File',
'path' => '/path/to/custom/place/'
'scopes' => ['custom_path']
]);

      

0


source







All Articles