
For agency owners providing website development and maintenance services, coming across errors on clients’ websites can be challenging. Bugs and glitches can really turn people off. It shows people that something is not right behind the scenes.
However, of course, it’s important to remember that no software is flawless. Problems or bugs may arise, especially when WordPress is powered by various themes and plugins.
Adopting best practices and taking a proactive approach is crucial to address these concerns, leading to smoother operations. One effective method to monitor and troubleshoot potential site issues is maintaining and reviewing an error log.
There are a couple methods through which you can set up and access WordPress error logs. In this article, I will tell you how you can enable and access your WordPress error logs. We will also explore the smart option of automatic updates.
- What Are WordPress Logs and Why Are They Important for Troubleshooting?
- How to Enable WordPress Error Logs
- How to Disable WordPress Debug Mode
- How to Find or Access WordPress Error Logs
- How to Fix Issues Found in WordPress Logs
- How to Use Error Logs to Identify and Resolve Performance-Related Issues
- How to Automate Updates With Cloudways SafeUpdates
- SafeUpdates’ Automated Testing Feature: How Does It Work?
- Best Practices for Troubleshooting with WordPress Logs
- Final Thoughts
What Are WordPress Logs and Why Are They Important for Troubleshooting?
Error logging involves tracking and monitoring website issues by maintaining a record of simple text files on the web server. These files are updated whenever an error occurs, allowing for the identification and analysis of problems.
The error log comprises error messages, along with their respective dates and times of occurrence. By enabling WordPress debug mode, these messages are gathered in a file for future review.
– Source: WordPress.com
WordPress error logs serve as a valuable troubleshooting tool for monitoring website issues, since they help identify problematic plugins, themes, or code.
By examining the error logs, you can point out common WordPress errors such as the WordPress White Screen of Death, 408 Request Timeout Error, or the SSH Connection Refused Error.
Now, let’s check out the process of locating and accessing your WordPress error logs.
Streamline Client Website Updates with SafeUpdates
Automate WordPress updates, enhance security and save valuable time with SafeUpdates. Experience an average of 42 hours saved on WordPress maintenance and triple your productivity.
How to Enable WordPress Logs?
The initial step involves activating WordPress debug mode, which can be accomplished either through a plugin or by implementing specific code.
Method 1: How to Enable WordPress Debug Mode with a Plugin
By default, WordPress does not enable error logging as debugging is turned off. To initiate error logging, the initial step is to install a WordPress debugging plugin such as the WP Debugging plugin or any other best WordPress debugging plugin. You can also use WordPress Query Monitor plugin to debug your WP site.
Once you have successfully activated the plugin, it automatically enables WordPress debug mode, allowing error messages on your website to be recorded and logged for analysis and troubleshooting purposes.
Method 2: How to Enable WordPress Debug Mode Using Code
If you are an advanced user, you can enable error logging and WordPress debug mode by playing with the wp-config.php file through sFTP access.
💡Note that this method requires caution, since making mistakes in the code can have serious consequences for your website.
Step 1. Connect to Your Website via sFTP
To begin, enable sFTP on your site.
- Navigate to My Site(s) → Settings → Hosting Configuration.
- Click on the “Enable SFTP” button.
You will receive your sFTP login details, including the URL, Port Number, Username, and Password. - Use some FTP software like FileZilla to connect to your site with these credentials.
Step 2. Locate and Download the wp-config.php File
- Locate wp-config.php in your website’s root directory.
- Download a copy of this file to create a backup.
Step 3. Edit the wp-config.php File
- Open the wp-config.php file using a text editor such as Notepad.
- Look for the line that says define(‘WP_DEBUG’, false); and replace it with the following code:
define('WP_DEBUG', true); if (WP_DEBUG) { @error_reporting(E_ALL); @ini_set('log_errors', true); @ini_set('log_errors_max_len', '0'); define('WP_DEBUG_LOG', true); define('WP_DEBUG_DISPLAY', false); define('CONCATENATE_SCRIPTS', false); define('SAVEQUERIES', true); }
With these changes, error logging and WordPress debug mode will be enabled.
Remember to keep this feature turned on only while troubleshooting, as leaving it active can potentially make your site more vulnerable to hacking attempts.
How to Disable WordPress Debug Mode?
For better WordPress performance and security, I suggest turning off debug mode. Leaving it on can make your website slower and even reveal sensitive information.
If you enabled debug mode with code, to disable error logging, simply remove the code you added and restore the following line:
define('WP_DEBUG', false);
If you’ve added a plugin for debug mode, you can turn it off by simply going to Plugins and deactivating the WP Debugging plugin.
Experience Error-Free Hosting with Autonomous
No more annoying hosting and limitation errors. With Autonomous, you can enjoy effortless scalability with Kubernetes-based autoscaling, super-fast speeds, and high uptime, ensuring your website remains fast and responsive.
How to Find or Access WordPress Error Logs?
After enabling WordPress debug mode, you must load your website to trigger any error codes, which will be stored in a file called debug.log. To access this file via sFTP, follow the same steps mentioned earlier.
To locate the debug.log file, navigate to the wp-content folder. If there are errors, the file will be visible. However, if there are no errors, the file won’t appear at all, indicating that everything is working smoothly.
Once you find the debug.log file, download it to your computer. You can then open it using text editing software like Notepad to view the complete log. The log will contain valuable information that can help you or your developer identify the source of the problem.
– wp log file opened in notepad
How to Fix Issues Found in WordPress Error Logs
The debug.log file provides valuable information about errors and warnings on your website but is not meant to be directly edited. Instead, you should use it as a reference to identify issues with your site, theme, plugins, or code.
To work with the debug.log file, follow these steps:
- Identify an error or warning in the debug log.
- Take note of the error code associated with the entry.
- Look up the meaning of the error code to understand the specific issue.
- Refer to separate guides or resources to find solutions for fixing that particular error.
When examining the debug.log file, each entry typically includes the date, time, module, process ID, and visitor’s IP address.
However, the most important part is the error message itself. For example, you may encounter errors like “File not found,” indicating a missing file and providing its path.
Once you understand the cause of the error, you can proceed to fix it. Common solutions include updating links to files that have been moved or deleted.
Occasionally, you may encounter notice errors (e.g., “bot detected for vhost”), which indicate that the server closed the connection. The debug log should provide further details on why the connection was terminated, such as detecting a potentially harmful bot.
Remember that the debug.log file is primarily for troubleshooting purposes and should not be directly modified. It serves as a valuable tool for diagnosing and resolving issues on your website.
How to Use Error Logs to Identify and Resolve Performance-Related Issues
There are numerous types of WordPress error logs that one can encounter, and attempting to list all of them here would result in an extensive and exhaustive compilation.
But still, we can look at one example to see how one can look at error logs to identify and resolve performance-related issues.
For instance, permissions error…
A permissions error in the error log triggers a PHP warning. This type of error occurs when a file is being accessed with incorrect permissions.
One common scenario is when files are uploaded via SFTP without resetting the permissions through the wp-admin dashboard, resulting in incorrect permission settings. It’s important to verify the existence of the file mentioned in the error.
Example 1:
PHP Warning: The stream could not be opened for writing to the file "/path/to/yourblog/wp-content/themes/badperms/lib/css/theme.css" due to permission denied. This error originated in the file "/path/to/yourblog/wp-content/themes/WFTDAtv/lib/less/lessc.inc.php" on line 1418...
Example 2:
[Sat May 31 21:30:22 2023] [error] [client 127.0.0.1] PHP Warning: The stream could not be opened for writing to the file "/path/to/yourblog/wp-content/themes/yoo_phoenix_wp/cache/xml-80a72b04a693554d055946d5ad954588.php" due to permission denied. This error occurred in the file "/path/to/yourblog/wp-content/themes/yoo_regvis_wp/warp/helpers/xml.php" on line 34. Referring page: http://example.com/wp-admin/customize.php
In certain cases, such an error may indicate that a plugin or theme is attempting to perform an action that is not permitted or trying to access a file or directory that it should not have access to.
Example 3:
PHP Warning: Failed to open the stream for writing to the file "/path/to/yourblog/wp-content/cache/autoptimize/autoptimize_f7d7e4c8e9a3146b6b514d7e7f9e2468.php" due to permission denied. This error originated in the file "/path/to/yourblog/wp-content/plugins/plugin_folder/plugin_file.php" on line 22...
How to Automate Updates With Cloudways SafeUpdates
It’s 2024. Tasks DON’T have to be complicated.
Running an agency is like juggling a million balls already. And updating WordPress can suck up hours, sometimes even days.
On top of that, frequent “500 Internal Server”, “503 Service Temporarily Unavailable”, or “409 Conflict error” during these updates can interfere with important tasks you are working on. Its stressful.
Therefore, it’s smart to explore ways in which your website automatically does some of the heavy lifting. One way Cloudways can help you avoid confusion and frustration is through our optional add-on, SafeUpdates.
SafeUpdates by Cloudways for WordPress is an optional add-on that automates WordPress updates by simplifying the process of detecting, testing, and deploying core, theme, and plugin updates.
Whether you’re a busy web creator or a business owner, it will take you a couple of clicks to put your WordPress site on autopilot. And if you are a Cloudways user, you can have this revolutionary feature for as low as $2/month per application.
The add-on gives you total control. You can update instantly or schedule for a time that works best for you. Plus, SafeUpdates is super easy to use right from the Cloudways dashboard.
— Image shows scheduling on SafeUpdates
With its automated workflow, SafeUpdates ensures efficient and confident update scheduling, freeing up your time for more important business tasks.
SafeUpdates’ Automated Testing Feature: How Does It Work?
For developers and agencies responsible for managing client sites, SafeUpdates’ Automated Testing feature is a game-changer.
When updates (core, theme, and plugins) are detected, SafeUpdates automatically triggers a series of actions to initiate the update process. It starts by taking a fresh backup, which is crucial when handling client sites to ensure data integrity and provide a safety net in case anything goes wrong.
Before deploying the updates, SafeUpdates creates a temporary staging environment where it conducts comprehensive tests. These tests cover critical aspects such as Visual Regression, Performance, Logs, and HTML checks.
By thoroughly assessing the updates in a controlled environment, you can identify and address any potential issues before they impact the live site.
Once the updates pass their tests, it automatically pushes them live, so your clients get the latest and greatest, like security enhancements and bug fixes, right away. If something goes wrong during testing, it quickly rolls back the updates, so your site never goes down.
As a developer or agency, automating the update process and conducting thorough testing saves you time and reduces the risk of errors or compatibility issues. SafeUpdates keeps you informed throughout the entire process, even sending notifications on the status of the updates.
This level of transparency allows you to stay on top of the update process and keep your clients informed.
A tool like this streamlines your workflow, minimizes risks, and keeps websites running smoothly.
Best Practices for Troubleshooting with WordPress Logs
WordPress logs can help you find and fix problems big and small. But just like any tool, they need to be used right. Here are some tips for getting the most out of them:
- Set a Log File Limit
If your error log grows too large, it could consume disk space and slow down your site. Set up a script or configure your server to automatically delete logs older than a certain number of days, or maybe even manually review and delete large log files time to time.
- Fix common errors
Figure out the common, repetitive errors. For example, avoid exceeding memory limit by increasing memory in wp-config.php or disable recently added plugins to avoid plugin conflicts. Another example of a common issue is theme errorss.
- Always backup!
Always make a backup before you start dabbling with your website based on what you find in the logs. That way, if something goes wrong, you can simply hit the reset button.
- Automate updates
Set up error log monitoring with automation tools. You can use SafeUpdates by Cloudways. It automatically detects, tests & deploys WordPress updates while you focus on growing your business.
- Monitor server logs
Don’t just look at WordPress logs. Check your hosting server’s logs too. These can reveal problems like running out of resources or server glitches. Most hosting control panels make it easy to find these logs.
- Debug during production
As mentioned above, once issues are resolved, turn off debugging to prevent unnecessary logging as well as any potential security risks.
Final Thoughts
WordPress error logs are crucial for effective troubleshooting and maintaining a reliable online presence. They allow you to identify and resolve errors on time, safeguarding your site’s reputation and visitor experience. Plus, backups and a staging area are like safety nets, giving you a way to undo mistakes if something goes wrong.
To make your workflow even better and save a boatload of time, Cloudways offers SafeUpdates. It automates safe updates for WordPress sites, eliminating the need for any manual intervention at all to enable WordPress logs.
Q. Where can I find WordPress logs?
A. To access your error logs, go to the /wp-content/
folder in your File Manager and look for the debug.log
file. This file stores all logged WordPress errors for easy review and troubleshooting.
Q. What are WordPress logs?
A. The WordPress error log is a valuable troubleshooting tool to point out the source of issues caused by any plugins, themes, or code.
Q. What is debug log WordPress?
A. WordPress offers a built-in debug tool that helps identify the root cause of errors on your website. While it provides valuable information, it is not recommended to enable it on a live public website due to potential security risks.
Q. Is it safe to edit errors in WordPress log file?
A. While you can edit the file, it’s generally not recommended. Editing the file directly may introduce new errors or delete important information, which is a big risk.
Q. Can I delete the WordPress error log?
A. Yes, you can delete the error log file. But know that this will erase all recorded errors.
Q. Does WordPress have an activity log?
A. Yes, WordPress has an activity log, which records user actions and system events. You can access it through the admin dashboard under “Tools” -> “Activity Log.”
Q. Where is the PHP error log in WordPress?
A. The PHP error log is usually located in your WordPress installation’s root directory, in a file named wp-content/debug.log
.
Abdul Rehman
Abdul is a tech-savvy, coffee-fueled, and creatively driven marketer who loves keeping up with the latest software updates and tech gadgets. He's also a skilled technical writer who can explain complex concepts simply for a broad audience. Abdul enjoys sharing his knowledge of the Cloud industry through user manuals, documentation, and blog posts.