Welcome Guest, Not a member yet? Register   Sign In
Don't log 404 errors in error log
#1

On our live site we get a lot of 404 errors from our site been probed by bots looking for phpMyAdmin/wordpress etc. This is filling up our log files with loads of  "404 Page Not Found: Phpmyadmin2015/index" etc.

What's the best way to stop any 404 errors being logged into our log files?

Many thanks!
Reply
#2

Not sure if my question is not clear or if it's just nobody knows?!
Reply
#3

I assume you are talking about the logs that CodeIgniter creates and not server or php logs.

Perhaps the least hackish way would be to extend the core class CI_Exceptions and override the method show_404. All the override has to do is call the parent method setting the second parameter to false.

The whole class definition is simple.

/application/core/MY_Exceptions.php

PHP Code:
class MY_Exceptions extends CI_Exceptions
{
 
    public function show_404($page ''$log_error TRUE)
    {
 
        parent::show_404($pageFALSE);
 
    }


The hack way to accomplish your goal is to modify CodeIgniter.php and change line 494 (version 3.1.6) from

PHP Code:
show_404($RTR->directory.$class.'/'.$method); 
to
PHP Code:
show_404($RTR->directory.$class.'/'.$methodFALSE); 
Reply
#4

Ah great idea to extend the exceptions. nice and clean.

Thanks!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB