-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception logging no longer occurs on CakePHP 4.4+ #12
Comments
Any idea what needs to be done? |
Looking at what cakephp/debug_kit does https://github.com/cakephp/debug_kit/blob/344fd1afe381e1901bda1a279955c1adf69d6b6d/src/Plugin.php#L97-L120 need to change to an Event listener. But I'm not sure as the new ErrorTrap and ExceptionTrap aren't very well documented and a lot of the docs reference old methods/solutions. |
What kind of docs are you looking for? The book should have the basic usage scenarios covered. |
@markstory Well my use case is I want all logging/errors sent to papertrail which I can configure via monolog/monolog. With the Error/Exception trap stuff there's no longer documentation on using monolog/monolog. |
Ok. I'm not familiar with how this plugin does logging, but for the core Error/Exception handling the default behavior is to log to |
Well this plugin just captures errors/exceptions and displays them nicely. My use case is in production, I'm not really trying to use it more directly, I'm trying to understand why exceptions are no longer logged using |
I'm not sure why you wouldn't be getting logs with the default error handling with 4.4, as the default error logger is ErrorLogger which uses |
No its Exceptions that aren't being logged. |
Ok, but both exceptions and errors use the same logger class in 4.4. Does your application define the |
Yep the default from cakephp/app, copied it over after 4.4.0 was released. But if you install this plugin or challgren/papertrail-logger both do not log exceptions because of the changes. Yes I understand I can add more debugging to the libraries but when an exception is not capture its real hard to figure out whats going on. And thats why I say there needs to be more documentation. If you were to do
You'd expect exceptions to be caught because I'm setting the default to be monolog/monolog and then I drop the debug and error Log configurations, expecting the default Log config to capture exceptions and errors. |
I agree, I would expect that logger to be called when logging the error. You're sure that your custom logger is being created? I'll try to make time later this week to reproduce with a similar setup to your plugin. |
Yep 100% sure its configured as I am seeing regular Log messages that I create. My controller action is /**
* Display error check testing
*
* @return void
* @throws \Exception
*/
public function errorCheck(): void
{
$this->log('Error Check: Emergency', LogLevel::EMERGENCY);
$this->log('Error Check: Alert', LogLevel::ALERT);
$this->log('Error Check: Critical', LogLevel::CRITICAL);
$this->log('Error Check: Error', LogLevel::ERROR);
$this->log('Error Check: Warning', LogLevel::WARNING);
$this->log('Error Check: Notice', LogLevel::NOTICE);
$this->log('Error Check: Info', LogLevel::INFO);
$this->log('Error Check: Debug', LogLevel::DEBUG);
$this->viewBuilder()->disableAutoLayout();
deprecationWarning('Dont do this');
throw new \Exception('Error Check: Exception');
} |
Exception BTW, Errors are logged fine, its exceptions that are not logged. |
I took a look at this further, and without this plugin installed, exception logging is working fine. However, when this plugin is installed logging doesn't work because the implementation in this plugin doesn't call
The comment above this line implies that not calling These problems might be resolvable if this plugin implemented an |
Please take a look at #13 |
Using version 1.0.0 of this plugin along side CakePHP 4.4.1 with the updated Exception and Error traps. Exceptions are no longer logged. This occurs even when debug is false.
The text was updated successfully, but these errors were encountered: