loading

What's Really in Your Server Error Logs?

When something goes wrong with your server, the first thing you check is the error log. But honestly, I had never really looked into what was piling up in that file before. So, I dug through 90,151 lines of Apache error logs from 30 days. The results were totally different from what I expected. There were virtually no lines left that were due to my server making a mistake. Not a single line indicated a PHP crash or a warning; out of the 90,151 lines, 89,454 were generated by requests coming from the outside. Even though it's called an error log, it's more like an attack record book.

What Was All That Log Data Made Of?

Log Entry Type Count Percentage
Attempt to execute a non-existent PHP file 58,396 64.8%
Requests blocked by security rules 25,539 28.3%
Attempt to list directory contents 2,638 2.9%
Requests trying to escape the path 1,858 2.1%
Exceeded internal redirect limit 1,023 1.1%
Other (server start/stop, etc.) 697 0.8%
Apache error log analysis chart
There were zero lines left due to PHP errors over the 30-day period.

The vast majority of entries were failures when someone tried to run a PHP file that didn't exist. This is basically attackers trying to probe your server by guessing filenames, and since the files aren't there, Apache logs an entry for each attempt. That averages out to about 1,946 lines per day. These lines actually prove your server is running normally, but they get logged as errors.

The Fact That There Were Zero PHP Errors

For the past 30 days, PHP hasn't logged a single critical error or warning. While this means the site is running smoothly, it also highlights just how inefficient it is to hunt for your own bugs within a massive file. If even one line out of 90,151 is the one you need to fix, finding it is like looking for a needle in a haystack. In reality, when a site goes down, you often just end up scrolling through endless scanner activity in the error log.

Your Blocking Rules Are Working

The second largest chunk, 25,539 lines, consists of records showing that the rules you set up successfully blocked requests. I took a look at what was being blocked.

Blocked Target Count
Files in the .env directory 19,497
The .git folder 5,488
Total 25,539

The .env file usually holds sensitive info like database passwords or API keys, and the .git folder contains your entire source code. Neither of these should ever be accessible via the web. I noticed variations like .env.backup, .env.local, .env.production, .env.bak, and .env.old as people try to find them by slightly changing the file name. This points to a habit where developers leave copies behind when deleting the original.

These blocked requests were spread across all 16 sites hosted on this server. It wasn't targeted at just one specific site; it was a broad sweep across an entire IP range, hitting every domain found. This pattern is the same as what I've seen from people looking for the .git folder on someone else's server, but this time, because I implemented blocking rules, all those attempts were recorded as blocked. Without those rules, these 25,539 entries would have been successful 200 responses in the access logs, not errors.

Those 1,023 Lines Apache Called a Configuration Error

I was pretty surprised by this one. There were 1,023 lines that said something like "looks like a configuration error." This meant Apache gave up on a request because it went through more than ten internal redirects. If you take the message at face value, you think it's a problem you need to fix.

To figure out where these requests were coming from, I checked the access logs from that time. For a single IP address in the same second, the requests looked like this: a non-existent administrative file inside the theme folder, an upload script in the plugin folder, an unknown PHP file in the root directory, and a path that looked exactly like an intrusion tool's name. The referring page had a search engine URL, but the format was off, and the browser name was misspelled. This wasn't a request from a human.

In short, those 1,023 lines weren't a configuration error; they were an illusion created by a scanner. When it hits a non-existent path, the redirect rules chain together, and at the end, Apache spits out a message suggesting a settings issue. If you only looked at that message and started digging through your config files, you would waste time looking in places where nothing was wrong. What the logs tell you isn't always the whole story.

2,638 Directory Listing Requests

The third group of entries was requests asking to see a directory listing. Of those, 1,438 were all hitting the same path. This is a default empty document folder that comes with Apache installation. Since there wasn't a file to serve as the homepage, it tried to list the contents but was blocked. If you set up your entire site using virtual hosts, this default folder wouldn't be used, but requests coming directly to the IP address without a domain fall into it.

The rest were requests for resources in the upload and admin folders. Even though the listing was blocked, the result is the same: if you leave default settings in place, you'll keep generating logs in places you don't even use, just like when the configuration files overlapped and the logs were doubled.

How to Actually Read Error Logs

Based on what we measured, we decided on two key strategies. First, when something goes wrong, you shouldn't just open the entire error log. If you filter out the three common messages left by scanners, the remaining lines drop to less than 1%. We went from 90,151 lines down to just 697.

Second, even if Apache throws an error saying there's a configuration issue, you should start by checking where that request came from. Usually, if you find the same IP address at the same time in your access logs, you'll find your answer.

On the flip side, there are things we decided not to touch. We are not blocking the scanner entries that accumulate in the error log. These lines are proof that your blocking rules are actually working, and if you delete them, you lose the ability to tell if attacks are increasing or decreasing. It's about 90,000 lines a month, which isn't a huge amount of space.

Measurement Methodology

We read 90,151 lines by combining five Apache error log files. The timeframe covered a 30-day period, starting from midnight on August 30th and ending at 3:27 PM on September 28th. We categorized the line content based on the fixed messages Apache generates, and if two messages appeared on the same line, we counted it only once. Directory listing requests are one such case, where the message "file not found" and "directory listing is forbidden" appear together on one line.

There are two limitations to this measurement. First, since this server hosts sixteen different websites, the line count is mixed with traffic from other sites. If you were running a server with only one site, the number would definitely be lower, but the overall ratio probably wouldn't change much because scanners don't care about domain names.

Second, this measurement won't show problems that don't generate an entry in the error log. Issues like slow response times or when the server returns incorrect information with a normal status code need to be tracked separately using access logs and response time metrics.