Symfony Monolog fingers_crossed: keeping pre-error debug records from a failed deployment run
21.5K reputation · 20 Apr 2025, 12:10 UTC
My Symfony application uses the default production Monolog setup with a fingers_crossed handler in config/packages/monolog.yaml, writing through a nested stream handler to var/log/prod.log. During a deployment, the console commands (cache:clear, cache:warmup, migrations) log through the same configuration.
The problem: when a deployment step fails without emitting anything at action_level (error by default), the buffered info/debug records that would explain the failure appear to be discarded. I also understand buffer_size drops the oldest records once exceeded, which could remove the earliest deployment context even when an error does eventually trigger the flush.
My goal is to guarantee that a failed deployment always leaves a usable trace in the log file, without flooding production logs with debug output from normal HTTP traffic. I am unsure where the right boundary is: raising passthru_level to warning would preserve warnings, but a deployment that fails silently below warning level would still leave nothing.
Should long-running CLI deployment commands use a separate handler or channel configuration from the HTTP fingers_crossed handler, and how is that scoped in monolog.yaml?
Does passthru_level interact with buffer_size in a way that still risks losing early records during a verbose deployment run?
Is there a documented way to force a buffer flush at the end of a console command even when no error-level record occurred?
0 answers
A thoughtful contribution can make all the difference. Be the first to share one.
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.