Technical Mid Level

How do you configure logging in a Symfony application? Explain Monolog channels, handlers, and how you structure logging differently for development versus production.

Quick Tip

In prod I use a fingers_crossed handler — it buffers debug-level logs silently, but if an error occurs, it flushes the entire buffer. That gives me full context around errors without logging everything all the time.

What good answers include

Symfony uses Monolog via the MonologBundle. Handlers define where logs go (file, stderr, Slack, Elasticsearch). Channels group log messages by topic (doctrine, security, app, custom). In dev: log everything to a file with a low threshold. In production: stream errors to stderr, send critical alerts to Slack or email, and rotate file logs. Config lives in config/packages/monolog.yaml, split by environment. Strong candidates explain: creating custom channels for domain-specific logging, using fingers_crossed handler to capture debug logs only when an error occurs, and the difference between bubble true and false for handler chaining.

What interviewers are looking for

Tests operational awareness. Candidates who use error_log or dump in production have no structured logging strategy. Those who understand channels, handlers, and the fingers_crossed pattern can debug production issues efficiently.

← All Symfony questions