In this blog post, we’ll explain what log files are, why WordPress administrators need to care about them, and the five important log files you need to know about.
What are log files?
Log files are files that record every activity on a server or a website. They contain information about every request made to the server, any errors that occurred, and other details that help diagnose issues.
Many software and devices have log files, we limit this article to the ones relevant to WordPress administrators and site owners.
Why do we need log files?
Logs can help WordPress site owners and administrators identify and troubleshoot issues on their websites. They provide insights into what is happening behind the scenes and can help diagnose problems that may not be immediately visible on the site.
Depending on the role of the user and the type of website, the purpose for analyzing logs is one or several aspects:
Logging mechanisms that intend to answer the question: who did what at which time?
Many regulations require businesses to keep records of past processes and events.
Log files are an important part of performance monitoring to understand system load and response times.
Logging mechanisms are a critical component of any IT security strategy for preventing, identifying, and minimizing the impact of cyber attacks.
This covers all aspects of analyzing technical issues like software errors and error messages.
- UI/UX Research
There are specialized tools for user interface and user experience research that record interactions of users with the system to identify problems with the user experience.
We focus in this article on the compliance, security, and troubleshooting aspects.
The most important log files
Several logs can be useful for WordPress site owners to know about, but we’ve narrowed it down to the five most important ones.
Web server access log
Web server access logs record every request made to your website. They contain information such as the IP address of the visitor, the page they visited, and the time and date of the request. These logs can help you understand your website traffic, identify popular pages, and detect any suspicious activity.
WordPress is a PHP-based application and as such often runs on an Apache or NGINX web server.
Apache access log
The Apache access log storage location is determined by the ErrorLog directive.
By default, you can find the Apache access log file at one of the following paths:
Depending on your web hoster, you can also access the web server logs via their administrator panel (e.g. cPanel).
NGINX access log
The NGINX access log storage location is determined by the access_log directive.
By default, you can find the NGINX access log file at one of the following paths:
Web server error log
As the name indicates, web server error logs record any errors that occur on your website. These could be 404 errors (page not found), 500 errors (internal server error), or other types of errors. These logs can help you identify issues with your website’s code or configuration.
The location of the error log again depends on the web server and below is the info for the commonly used Apache and NGINX web servers.
Apache error log
The Apache error log storage location is determined by the ErrorLog directive.
By default, you can find the Apache error log file at one of the following paths:
Depending on your web hoster, you can also access the web server error logs via their administrator panel (e.g. cPanel).
NGINX error log
The NGINX error log storage location is determined by the error_log directive.
By default, you can find the NGINX error log file at one of the following paths:
PHP error log
PHP error logs record errors that occur in your website’s PHP code. These could be syntax errors, fatal errors, or warnings. These logs can help you identify issues with your website’s code and troubleshoot them.
There are various PHP configuration options for error reporting. This includes the folder in which the PHP error log is stored in and which type of errors should be included. All error reporting options are controlled via directives set in one or multiple php.ini files.
error_log holds the path to the error log file.
Typical php.ini locations include:
(path changes according to PHP version – here version 8.2 as an example)
(again: PHP version dependent)
You can check on the loaded php.ini file by using a PHP file that either calls
WordPress debug log
WordPress debug log records errors and warnings generated by WordPress and its plugins. It can help you identify issues with your website’s plugins or themes, and troubleshoot them. Think of them as a subset of the PHP errors discussed above.
To enable the WordPress debug logging, you need to update your wp-config.php file which is located in the root of your WordPress file directory.
Toward the last third of the file, you will see something like this:
define('WP_DEBUG', false); define('WP_DEBUG_LOG', false);
Changing the values from
true enables the debug mode and logging to the WordPress debug.log file.
Here is an example:
define( 'WP_DEBUG', true ); // Enable WP_DEBUG mode define( 'WP_DEBUG_LOG', true ); // Enable logging to log file // Disable display of errors and warnings (recommended for production sites) define( 'WP_DEBUG_DISPLAY', false ); @ini_set( 'display_errors', 0 );
The default location for the WordPress debug.log file is:
You can change the default location by setting WP_DEBUG_LOG to a valid file path instead of the true value shown above. More information on this can be found in the WordPress debugging documentation.
WordPress activity log
Activity logs record every action taken on your website, such as when a user logs in, when a post is published, or when a plugin is activated. These logs can help you identify suspicious activity and keep track of changes made to your website.
Our plugin WP Admin Audit features a detailed event log showing the various changes initiated by the WordPress admins and users.
The WordPress data domains covered include:
Each domain features multiple different event types which we refer to as Sensors and which can be individually enabled and disabled.
You can audit suspicious user accounts or check if your site is under brute-force attacks by bots.
In conclusion, log files are an essential tool for WordPress administrators and site owners. They provide insights into what is happening behind the scenes and can help diagnose issues on your website.
By knowing about and utilizing the five different types of logging mechanisms we’ve covered, you can identify and troubleshoot issues with your WordPress website and ensure it runs smoothly.