267-587-7288 CALL OR TEXT

Most people who own websites are oblivious to the technical details that make it work, and they should be if they’re running a non-technical business. It does help (at times) to have a few dangerously valuable tidbits of information in case something goes wrong. Much like knowing in your car if one of the engine lights comes on – to find an expert to fix it.

Your WordPress website is built in a programming language called PHP. In the early days of the Internet, web pages had file extensions like .php, .php3, and static sites had .htm and .html pages. Since WordPress has “pretty permalinks” to make the URL’s search friendly like www.site.com/about-my-site – you never see that the files running the site are PHP (unless you have to delve into the code).

What Happens When Web Pages Load?

When your website serves a page to a user, many thing happen all at once. Multiple files are called, scripts are included, and the database is queried to get your content (for that page) and the code (with images) is sent to the users browser to display the page.

If something goes wrong, the majority of websites print the PHP errors to a flat text file called “error_log” in the root of your website, along with the date and the time it happened. As the website owner, you don’t receive an email, you’re not notified – and if you don’t know to periodically check for this file (and it’s contents), you won’t even know your website is generating errors.

Error Log Entries

Here’s a tidbit from a sample error log entry:

php error log

In that example a WP plugin that uses ebay to get results is failing every time a search happens. We had no idea this was going on (the plugin wasn’t telling us), and we were still getting some results on the front end of the website. Even though the plugin does work somewhat, the error happens every time (telling us something is wrong).

Imagine what happens when plugins break, themes become incompatible with new WordPress releases, or external script calls to places like Google, Facebook, Yahoo, or Amazon don’t work right? That’s right – more errors.

We had a instance last month where a client had an 8GB php error log file (yes GIGABYTE). The error_log had been collecting errors from the theme. Every time a page loaded, it created 2 php error entries – and it did that for the last 3 YEARS!

What Can you Get from the Error Log Entries?

You would be surprised what you can sometimes glean from those error log entries. You always get a date and time the error happened, followed by some indication of the type of error. Sometimes you get a physical location of the file causing the error, and/or an actual line of code that generated it.

Other times you might get a reason like “server went away”. This happens a lot with database requests – and it’s helpful to know that the error happened because the database server either wasn’t available (or ran out of resources). If this happens all the time – you have a real issue that needs to be fixed.

You might even get some errors that indicate a hacker or script attempted to force your website or database to do something so they could break in (like inject code or call illegal operations).

How do I Manage My PHP Error Log?

The first thing you should know is that your error_log exists (if your site has generated at least one error). Check the public_html or www root of your webhosting account and look for a file called “error_log” (with no extension). You can download that file and open it in a text editor (like Notepad) to see the entries.

The second thing that you should know is that any folder (that has PHP files) can have this file. The error_log in the root of your website is for the core WordPress files. If your theme or plugins generate errors, you could also have multiple error_log files in locations inside wp-content/themes or wp-content/plugins sub-folders. Sometimes it’s helpful to nose around and see.

One helpful way to view and manage your error_log is by installing the plugin error log monitor. You get a dashboard widget with the last PHP error log entries. More importantly you can configure the plugin to send you email (when errors are generated), and also delete your log file.

Most important of all – if you find an error that you can’t manage on your own – be sure to call in an expert to help. If you need assistance, be sure to view our WordPress development page for more information.