• I inherited a custom plugin that has some try-catch statements. I suspect one of them is failing occasionally. I would like to always log the error message in the catch clause. However, the articles I’ve found so far via google (here and here) all recommend wrapping logging in a WP_DEBUG check.

    Is there a way for me to log to WordPress’ standard debug/error log from a plugin regardless of WP_DEBUG being enabled, or is it working that way by design? I haven’t been able to reproduce the error, so I would prefer to not leave debugging active on my production site for any period of time in the hopes of catching this error in the wild.

    Thanks.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Use PHP’s error_log(). All messages (they don’t really need to be errors) end up in the standard PHP error log. Where that is depends on server settings, you should be able to get to it through your host’s cPanel.

Viewing 1 replies (of 1 total)
  • The topic ‘Best practice for logging errors in a plugin?’ is closed to new replies.