Title: How to catch error_log() errors
Last modified: October 1, 2020

---

# How to catch error_log() errors

 *  Resolved [mezzomedia](https://wordpress.org/support/users/mezzomedia/)
 * (@mezzomedia)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/how-to-catch-error_log-errors/)
 * I’ve double checked if my PHP integration is working properly, and I am successfully
   receiving PHP test error events in Sentry.
 * However, it seems that PHP errors that are written to the Apache error log from
   my WordPress plugin with `error_log()` are not received in Sentry.
 * Am I correct in assuming that `error_log()` is **not** picked up by the Sentry
   integration plugin?
 * And if not, how can I make sure application errors will be picked up by the Sentry
   integration plugin?
 * Cheers!
 * PS I have ‘WP_DEBUG’ set to true, ‘WP_DEBUG_DISPLAY’ set to false, and I’m not
   using ‘WP_DEBUG_LOG’ in favor of the default Apache logs.
    -  This topic was modified 5 years, 8 months ago by [mezzomedia](https://wordpress.org/support/users/mezzomedia/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [mezzomedia](https://wordpress.org/support/users/mezzomedia/)
 * (@mezzomedia)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/how-to-catch-error_log-errors/#post-13493538)
 * By replacing the occurrences of `error_log()` with `trigger_error()` I have been
   able to make Sentry pick up these errors properly, as well.
 * Questions still stands:
    Are errors logged with `error_log()` **not** picked 
   up by the Sentry integration plugin?
 *  Plugin Author [stayallive](https://wordpress.org/support/users/stayallive/)
 * (@stayallive)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/how-to-catch-error_log-errors/#post-13493575)
 * Hi [@mezzomedia](https://wordpress.org/support/users/mezzomedia/),
 * Sorry for the late reply, I forgot to reply to you 🙁
 * Unfortunately as far as I know this is a limitation of PHP.
 * `error_log` is described as: Sends an error message to the web server’s error
   log or to a file. ([https://www.php.net/manual/en/function.error-log.php](https://www.php.net/manual/en/function.error-log.php))
 * `trigger_error` is described as: Used to trigger a user error condition, it can
   be used in conjunction with the built-in error handler, or with a user defined
   function that has been set as the new error handler (set_error_handler()). ([https://www.php.net/manual/en/function.trigger-error.php](https://www.php.net/manual/en/function.trigger-error.php))
 * Sentry is able to detect `trigger_error` because it hooks into the error handler.
 * But as far as I know there is no API to hook into messages sent to the `error_log`
   function and that is why it will not be picked up by Sentry.
 * If I’m mistaken and there is a way I’m happy to learn about it but as far as 
   I can tell there is no way for PHP code to detect `error_log` calls and handle
   them.
 *  Thread Starter [mezzomedia](https://wordpress.org/support/users/mezzomedia/)
 * (@mezzomedia)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/how-to-catch-error_log-errors/#post-13493620)
 * Hi Alex,
 * Thanks for your extensive reply!
 * This clarifies the issue. Also, using `trigger_error()` instead of `error_log()`
   combined with WordPress’ logging options seems fine to me.
 * Cheers!
 *  Plugin Author [stayallive](https://wordpress.org/support/users/stayallive/)
 * (@stayallive)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/how-to-catch-error_log-errors/#post-13493701)
 * Yeah as far as I know `trigger_error` also ends up in the `error_log` so that
   should be what you want indeed 👍

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘How to catch error_log() errors’ is closed to new replies.

 * ![](https://ps.w.org/wp-sentry-integration/assets/icon-256x256.jpg?rev=1772463)
 * [Sentry for WordPress](https://wordpress.org/plugins/wp-sentry-integration/)
 * [Support Threads](https://wordpress.org/support/plugin/wp-sentry-integration/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-sentry-integration/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-sentry-integration/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-sentry-integration/reviews/)

## Tags

 * [error_log](https://wordpress.org/support/topic-tag/error_log/)
 * [log](https://wordpress.org/support/topic-tag/log/)
 * [wp_error](https://wordpress.org/support/topic-tag/wp_error/)

 * 4 replies
 * 2 participants
 * Last reply from: [stayallive](https://wordpress.org/support/users/stayallive/)
 * Last activity: [5 years, 8 months ago](https://wordpress.org/support/topic/how-to-catch-error_log-errors/#post-13493701)
 * Status: resolved