Error Log Monitor
Whether you’re using WordPress for development or simply as a blog or CMS, it is always a good idea to keep an eye on your PHP error log.
- As a developer, it helps you notice and fix errors in your code.
- As a normal user, it lets you discover plugin bugs, WordPress compatibility issues and other problems that may be affecting your site, so that you can fix them before they seriously hurt your readers and your search engine rankings.
That’s why I’ve created Error Log Monitor – a plugin that lets you easily view the most recent messages from your PHP error log in your Dashboard, and can even send you automatic email notifications about new errors.
- Dashboard widget displays the most recent messages from your PHP error log.
- Automatically detects the location of the log file.
- Provides instructions for setting up error logging if it’s not enabled yet.
- Periodically checks the log for new errors and emails them to you.
- Configurable email address and email frequency (from every 10 minutes to weekly).
- Configurable number of lines to display.
- Lets you easily clear the log file.
- The dashboard widget is only visible to administrators.
The plugin has only been tested on WordPress 3.4.x, but will probably work with any version from 3.0 and up.
- Upload and activate the plugin as usual.
- Go to your Dashboard and enable the “PHP Error Log” widget through the “Screen Options” panel.
- The widget should automatically display the last 20 lines from your error log. If you haven’t configured error logging yet, it will instead display instructions on how to do that.
- (Optional) To enable email notifications, go to widget configuration and enter your email address in the appropriate field.
- That’s it.
Before writing this plugin, I researched and tried a number of existing error reporting plugins. Unfortunately, most of them were either seriously out of date (no updates for more than two years), or didn’t support email notifications, which was the main feature I was looking for. So I decided to build my own.Related posts :
Regarding the log file: file ownership could be one problem. When you view that file in your FTP application/whatever, who shows up as the file owner? What about other WordPress-related files – do they have the same owner, or something else?
As for uploads, that seems completely unrelated to this plugin. Perhaps one of these posts will help:
would it be listed in phpinfo?
No I want to use this plugin to find the issue plus to know if something goes wrong.. I use filezilla where would it show me owner?
Thank you for you attempt to help me in resolving this issue. Hope we can get this nipped.
In FileZilla it would show up in the “Owner/Group” column. Depending on your FileZilla and server versions, it might be a username or a pair of numbers.
I login with the username of the host account…??? Its shred hosting should I contact go daddy?
Perhaps. Maybe they can help.
I am having some problems getting the app to recognise the location of php-errors
I am fairly certain that the location is properly described since it is consistent with the status report from FTP when I download it… namely /myLogs/logs/php-errors.log
Directory permissions are all set to 755 / flcdmpe
and the file to 644 / adfrw (though I would prefer 600.
Any comments would be welcome
You need to use the absolute path – that is, a path that starts with the root directory. What you have right now looks like a path that’s relative to your FTP home directory, and on most most servers the home directory is not the same as the system root directory.
Try the development version of the plugin:
This version will show the absolute path of your WP directory in the widget. You can probably figure out the full path of the log file based on that. If no, try asking your host for the absolute path – they should know.
I have tried your plugin on my development machine under Windows 7, XAMPP stack Version 3.2.2, PHP 5.6.19, WordPress 4.8.1.
The E-Mail notification is working, but I get error notices about your code:
New PHP errors have been logged on http://localhost/wordpress
Here are the last 6 entries from C:\xampp\htdocs\wordpress/php-errors.log:
[Aug 24, 10:25:25] PHP Notice: Undefined index: schedule in C:\xampp\htdocs\wordpress\wp-content\plugins\error-log-monitor\scb\Cron.php on line 69
[Aug 24, 10:25:25] PHP Notice: Undefined index: time in C:\xampp\htdocs\wordpress\wp-content\plugins\error-log-monitor\scb\Cron.php on line 76
[Aug 24, 10:26:25] PHP Notice: My User Notice in C:\xampp\htdocs\wordpress\wp-content\plugins\abi77\admin\class-plugin-name-admin.php on line 379
[Aug 24, 10:26:25] PHP Warning: My User Warning in C:\xampp\htdocs\wordpress\wp-content\plugins\abi77\admin\class-plugin-name-admin.php on line 380
[Aug 24, 10:28:18] PHP Notice: Undefined index: schedule in C:\xampp\htdocs\wordpress\wp-content\plugins\error-log-monitor\scb\Cron.php on line 69
[Aug 24, 10:28:18] PHP Notice: Undefined index: time in C:\xampp\htdocs\wordpress\wp-content\plugins\error-log-monitor\scb\Cron.php on line 76
Would it be possible to fix this?
The notices are thrown by scbFramework, a third-party library. That project is no longer maintained by the original developer, but I guess I can fix it myself. Try the development version of Error Log Monitor. It should get rid of those notices.
I have tried out your development version and it is working like expecting.
The error notices are gone and the E-Mail notification is still working.
Thanks for your fix,
Is there a way for the plugin to display timestamps in local time (not UTC/GMT).
I know there are some subtle issues with daylight savings time, but this would be less of an issue than having to mentally translate timestamps every time you view the log. Worst case, you can always look at the error log file directly for the unconverted times.
Sure. I’ll make that change for the next plugin release.
Fortunately, WordPress includes a utility function for converting from UTC to the local timezone: get_date_from_gmt(). It looks pretty inefficient, but it should work for this purpose.
If you’re worried about overhead of the conversion, consider an option for adding it to just the last log message displayed (or the last 5).
It’s probably not that bad, but sure, that could be an option.
Hi, We use wordfence for security on our site and they warn us that our log file for Error Log Monitor is a security risk. Here is their warning:
http://bearleaderchronicle.com/site/wp-content/debug.log is publicly accessible and may expose source code or sensitive information about your site. Files such as this one are commonly checked for by scanners and should be made inaccessible. Alternately, some can be removed if you are certain your site does not need them. Sites using the nginx web server may need manual configuration changes to protect such files.
Could you advise how to locate or otherwise configure Error Log Monitor so that the log file is not publicly accessible?
This is not something that’s configured inside Error Log Monitor. The plugin just uses the existing PHP error logging settings.
It sounds like you have WP_DEBUG_LOG turned on. This is a WordPress configuration constant that makes it log PHP errors to /wp-content/debug.log. Disable WP_DEBUG_LOG (i.e. set it to false) to prevent that.
Then you can use the PHP configuration option error_log to specify your own log file. You can set this option in php.ini, or by adding
ini_set('error_log', '/path/to/logfile');to your wp-config.php, or possibly even in .htacess. Please set it to the full path to the log file to ensure compatibility with Error Log Monitor. The log file needs to be writable by PHP.