![]() ![]() The process is very similar to the previous method, and requires the following two steps: Step 1: Create a log file If you have access to your site’s php.ini file, or if you are able to implement “per-directory” initiation files, this method will enable you to monitor PHP errors for any website, not just those powered by WordPress. Method 2: Error Logging via the php.ini file You may add any number of additional directives to enhance and customize your error-logging system as needed. First, if you place the following definition to your wp-config.php file, all WordPress debug errors will also be written to your php-errors.log file:ĭefine('WP_DEBUG', true) // enable debugging modeĪlso note that the code used for this example demonstrates a very basic implementation. Cool tipsĪ couple of notes regarding this method. See the code comments for more information on changing these settings. The current configuration is ideal for production sites, but you may want to enable PHP error display for development purposes. The other two directives in this tasty little snippet enable you to log and display PHP errors at your will. All PHP errors will now be logged to your php-errors.log file, thereby enabling you to monitor and resolve errors as quickly as possible. Once in place, edit the third line with the absolute directory path to the php-errors.log file created in the first step. Next, open your site’s wp-config.php file (located in the root WordPress directory) and place the following code immediately above the line that says, “ That's all, stop editing! Happy blogging.”: // log php // enable or disable php error logging (use 'On' or // enable or disable public display of errors (use 'On' or // path to server-writable log file Once this file is created, writable, and in place, take note of its absolute directory path and continue to the final step. This file may be placed in any directory, but placing it above the web-accessible root directory of your site is advisable for security reasons. Your server will need write access to this file, so make sure to set the appropriate permissions. This file will serve as your site’s PHP error log. Here’s how to do it: Step 1: Create a log fileĬreate an empty file called “ php-errors.log”. In this method, we will take advantage of this feature by implementing basic error monitoring for your site. The WordPress wp-config.php file may be used to specify various PHP initiation settings to modify the functionality of your PHP installation. Perhaps the easiest way to implement PHP error-logging for your WordPress-powered site is to add a few simple lines of code to your wp-config.php file. Method 1: Error Logging via the WordPress configuration file The first method is exclusive to WordPress, and the second two methods work great for any website. In this DiW article, we’ll show you three easy ways to monitor PHP errors for WordPress. Monitoring PHP errors is something that all responsible WordPress administrators should be doing. Even if your site appears to working properly on the surface, it may in fact be suffering from undetected PHP errors that should be fixed as soon as possible. PHP errors usually occur unpredictably and spontaneously, and may be triggered by even the slightest changes to your server configuration, database setup, or WordPress files. When left undetected, PHP errors can reduce performance, waste bandwidth, and leave your site vulnerable to malicious attack. ![]() ![]() Close monitoring of your site’s PHP errors is crucial to operating a healthy, secure, and well-performing website. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |