How to cut down page-not-found error records in your Watchdog table?

Some of you who own Drupal website may notice that now and then people are trying to hack your server with tons of call to phpMyAdmin/scripts/. I’ve checked all IP addresses that are used to visit my site, I found those in Watchdog table in DB. Those IP addresses are from all over the world such as China, Russia, Canada, USA, Ukraine, … you name it. This is very annoying when the watchdog table is loaded with not-found-page errors instead of system errors that you’re more interested in. Today I will show you how to stop all of these nonsense log from inserting into your Watchdog table.
Step 1: Open the common.inc file from /includes/ directory. Search for the function named drupal_not_found().

Step 2: Having some fun changing the way how Drupal inserting error to watchdog table. Add the codes below at the beginning of the function.

$get_error_text = check_plain($_GET['q']);
$pattern = "/config/i";

if(!preg_match($pattern, $get_error_text )){
//place this watchdog function call inside this condition
watchdog('page not found', $get_error_text, NULL, WATCHDOG_WARNING);
}

You’re done. Upload this common.inc file to your web server. You will notice that there’s no more log of this type of error recorded to your database again. All other interested errors are still recorded.