sentry-php icon indicating copy to clipboard operation
sentry-php copied to clipboard

Option to capture only exceptions in Monolog handler

Open mnow-cd opened this issue 3 months ago • 2 comments

Problem Statement

Currently, the Monolog\Handler handler sends both the message and the exception events to Sentry, if the exception key is present in the log context.

It would be very useful to have an option in Monolog\Handler to capture only exceptions and skip capturing plain messages, since those should be handled by other handlers (eg. LogsHandler).

Solution Brainstorm

Add a new option, e.g. $captureOnlyExceptions (default: false for backwards compatibility).

  • When false: keep current behavior (capture both message and exception).
  • When true: capture only the exception (if present in context).

mnow-cd avatar Sep 22 '25 12:09 mnow-cd

Hi @mnow-cd! Thanks for opening the issue. I will take a closer look and come back to you

Litarnus avatar Sep 23 '25 12:09 Litarnus