Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP error log - can I exclude 404 errors?

The error log of my CakePHP app is full of 404 errors. Can I exclude these MissingControllerExceptions from appearing in the error log? Using Cake 2.3.

like image 990
Will Avatar asked Mar 24 '14 10:03

Will


People also ask

What can be done to avoid error 404?

The simplest and easiest way to fix your 404 error code is to redirect the page to another one. You can perform this task using a 301 redirect. What's 301, you may ask? It's a redirect response code that signals a browser that the content has been transferred to another URL.

Should I log 404 errors?

By keeping a log of 404 errors, not only will you improve your website's user experience, but you'll also be able to: Quickly identify and fix broken links. Improve your website's search engine performance (SEO). Better identify suspicious behaviour such as “fuzzer” scans or website infections.

What is a 404 error log?

A 404 error message is a Hypertext Transfer Protocol (HTTP) status code indicating the server could not find the requested website. In other words, your web browser can connect with the server, but the specific page you're trying to access can't be reached.

How do you handle 404s?

Best Practices for Redirecting 404 Pages404s should not be redirected globally to the home page. 404s should only be redirected to a category or parent page if that's the most relevant user experience available. It's okay to serve a 404 when the page doesn't exist anymore (crazy, I know).


1 Answers

versions above 2.4 (as mentioned by null) have an undocumented feature for this purpose.

just modify your exception config:

Configure::write('Exception', array(
    'handler' => 'ErrorHandler::handleException',
    'renderer' => 'ExceptionRenderer',
    'log' => true,
    'skipLog'=>array(
        'MissingControllerException'
    )
));

skipLog takes names of exception classes to be excluded from log.

like image 90
Panter4 Avatar answered Oct 12 '22 11:10

Panter4