• Resolved mezzomedia

    (@mezzomedia)


    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 4 years, 1 month ago by mezzomedia.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mezzomedia

    (@mezzomedia)

    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

    (@stayallive)

    Hi @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)

    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)

    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

    (@mezzomedia)

    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

    (@stayallive)

    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.