[GH-ISSUE #1219] Output to Browser #510

Closed
opened 2026-03-04 02:15:36 +03:00 by kerem · 1 comment
Owner

Originally created by @ChristianFranke on GitHub (Nov 6, 2018).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1219

I'm using monolog successfully, but in case of unhandled PHP errors (e.g. Warning: Division by zero) this error message still appears in the browser.

Of course I can deactivate errors in the browser with display_errors = 0, but I would prefer an "anonymous" error message to be sent to the browser (e.g. "we are already on it"). I can overwrite this error message with set_error_handler, but then monolog doesn't get the error anymore - or do I see it wrong?

Another idea would be to write an echoHandler for monolog, but then PHP would still issue the error message.

What's the best practice here? Thanks for your answer!

Originally created by @ChristianFranke on GitHub (Nov 6, 2018). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1219 I'm using monolog successfully, but in case of unhandled PHP errors (e.g. Warning: Division by zero) this error message still appears in the browser. Of course I can deactivate errors in the browser with display_errors = 0, but I would prefer an "anonymous" error message to be sent to the browser (e.g. "we are already on it"). I can overwrite this error message with set_error_handler, but then monolog doesn't get the error anymore - or do I see it wrong? Another idea would be to write an echoHandler for monolog, but then PHP would still issue the error message. What's the best practice here? Thanks for your answer!
kerem 2026-03-04 02:15:36 +03:00
  • closed this issue
  • added the
    Support
    label
Author
Owner

@Seldaek commented on GitHub (Nov 19, 2018):

This is typically handled by the framework (responding with an error page when an unhandled error occurs). The best practice is definitely to run production with display_errors=0 because otherwise you might leak sensitive information to the user.

How exactly you go about rendering a page I am not sure, depends on how your application is built really, but I would say this shouldn't really be monolog's responsibility, as it's about reporting an error to the user and not about logging for devs. The goal is different and the information conveyed as well.

<!-- gh-comment-id:440078087 --> @Seldaek commented on GitHub (Nov 19, 2018): This is typically handled by the framework (responding with an error page when an unhandled error occurs). The best practice is definitely to run production with display_errors=0 because otherwise you might leak sensitive information to the user. How exactly you go about rendering a page I am not sure, depends on how your application is built really, but I would say this shouldn't really be monolog's responsibility, as it's about reporting an error to the user and not about logging for devs. The goal is different and the information conveyed as well.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#510
No description provided.