Issue
I am running a pretty big application, with a few thousand users and I like to check the log files (almost) daily, to see if something has gone wrong.
Fortunately the system is quite stable, but I am having a lot of Invalid CSRF token
, Record not found in table X with primary key [NULL]
, (and so on) errors. I usually ignore that kind of errors, since there is not much that I can do to avoid them.
Is there a way to tell the logger not to save those kind of exceptions in my log files?
Solution
Check the Error
section of your applications app.php
configuration file, specifically the explanation for the skipLog
option.
[...]
skipLog
- array - List of exceptions to skip for logging. Exceptions that extend one of the listed exceptions will also be skipped for logging. E.g.:'skipLog' => ['Cake\Network\Exception\NotFoundException', 'Cake\Network\Exception\UnauthorizedException']
[...]
You'd want to skip \Cake\Network\Exception\NotFoundException
and \Cake\Network\Exception\InvalidCsrfTokenException
.
If you need more fine-grained control, then you'd have to create a custom error handler and override for example BaseErrorHandler::_logException()
where you could inspect the exception and act accordingly.
See also
- Cookbook > Error & Exception Handling > Error & Exception Configuration
- Cookbook > Error & Exception Handling > Creating your Own Error Handler
Answered By - ndm
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.