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.

Features

  • 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.

Screenshots

The PHP error log Dashboard widget with some error messages

Widget configuration screen

Download

error-log-monitor.zip

The plugin has only been tested on WordPress 3.4.x, but will probably work with any version from 3.0 and up.

Installation

  1. Upload and activate the plugin as usual.
  2. Go to your Dashboard and enable the “PHP Error Log” widget through the “Screen Options” panel.
  3. 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.
  4. (Optional) To enable email notifications, go to widget configuration and enter your email address in the appropriate field.
  5. That’s it.

Notes

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 :

40 Responses to “Error Log Monitor”

  1. Jānis Elsts says:

    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:
    http://ecarobar.com/increase-max-upload-file-size-in-wordpress/
    http://www.wpbeginner.com/wp-tutorials/how-to-increase-the-maximum-file-upload-size-in-wordpress/

  2. Tony says:

    would it be listed in phpinfo?

  3. Tony says:

    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?

  4. Tony says:

    Thank you for you attempt to help me in resolving this issue. Hope we can get this nipped.

  5. Jānis Elsts says:

    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.

  6. Tony says:

    I login with the username of the host account…??? Its shred hosting should I contact go daddy?

  7. Jānis Elsts says:

    Perhaps. Maybe they can help.

  8. JohnN says:

    Hi
    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

  9. Jānis Elsts says:

    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:
    https://downloads.wordpress.org/plugin/error-log-monitor.zip

    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.

  10. Frank says:

    Hi Janis,

    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?

    Best Regards
    Frank

  11. Jānis Elsts says:

    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.
    https://downloads.wordpress.org/plugin/error-log-monitor.zip

  12. Frank says:

    Hi Janis,
    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,
    Frank

  13. Eric says:

    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.

  14. Jānis Elsts says:

    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.

  15. Eric says:

    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).

  16. Jānis Elsts says:

    It’s probably not that bad, but sure, that could be an option.

  17. Mark says:

    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?

    Thanks!

  18. Jānis Elsts says:

    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.

  19. fabio piferi says:

    HI,
    I have problems with NextGEN Gallery plugin that do not open a gallery when selected, but only the title.

    Do you have any idea about the reason?

    Until now I not have received any mail message for this error.

    Moreover I do not find any widget related to errors log.
    I have modified as required the wp-config.php file.

    Thanks in advance for the support.

    Fabio Piferi

  20. Jānis Elsts says:

    Sorry, I can’t provide help with other plugins. You might have better luck asking the people who actually made that plugin.

    As for the widget, try this: open the “Screen Options” panel in the dashboard and make sure that the “PHP Error Log” option is enabled. If that option is missing, the plugin might not be active, or the widget might be hidden by another plugin.

    Finally, Error Log Monitor can only show PHP errors. If whatever problem you’re having with NextGEN Gallery was not caused by a PHP error, ELM might not be very useful in solving it.

Leave a Reply