Product Decisions This Supports
- Observability & Debugging: Enable deeper visibility into CLI command execution for debugging, auditing, and performance analysis — now including what a command actually printed, not just exit status and timing.
- Operational Efficiency: Reduce manual logging efforts by automating command execution tracking (e.g., cron jobs, migrations, or custom scripts). Support tickets that used to require re-running jobs with
-v can now be answered from the log.
- Compliance & Auditing: Maintain a tamper-proof log of command executions for security or regulatory requirements (e.g., GDPR, SOC2). Captured output adds evidence of what changed, not just that a command ran.
- Performance Optimization: Identify slow or failing commands via execution time and error metrics, prioritizing fixes. Output capture pairs naturally with failure forensics (stack traces, tool error messages).
- Incident Response: Post-mortem a failed nightly job without reproducing it — the stored output is the artifact, which shortens MTTR for non-reproducible failures.
- Build vs. Buy: Avoid reinventing logging infrastructure; leverage a lightweight, open-source solution with minimal maintenance overhead. Output capture is a capability most teams would otherwise hand-roll in a wrapper script.
- Roadmap for CLI Tools: Expand existing CLI tooling (e.g., Symfony-based projects) with built-in logging for internal tools or developer workflows.
When to Consider This Package
-
Adopt if:
- Your project uses Symfony CLI commands and needs structured logging (e.g., cron jobs, migrations, or custom scripts).
- You require audit trails for command executions (e.g., tracking who ran what and when).
- You need to debug performance issues (e.g., slow commands, timeouts) or error rates in production.
- You need failure forensics — post-hoc visibility into what a command printed when it failed, without re-running it.
- Your team lacks time to build a custom logging system but needs minimal setup (attribute-based or config-driven).
- You’re using Symfony 7/8 and Doctrine ORM 3, as the package is actively maintained for these versions.
-
Look elsewhere if:
- You need real-time monitoring (e.g., dashboards, alerts) – consider integrating with tools like Sentry, Datadog, or ELK Stack.
- Your commands are not Symfony-based (e.g., pure PHP scripts, Node.js, or Python).
- You require advanced filtering/aggregation (e.g., querying logs via SQL) – the package provides basic CLI filtering but no API.
- You’re in a high-security environment where MIT-licensed packages are restricted (though MIT is permissive, check compliance policies).
- You need log retention beyond 100 days without manual purging (configurable but not dynamic).
- Commands emit secrets or PII and you cannot reliably scope output capture. Output logging is opt-in per command/flag, so this is a configuration discipline problem rather than a blocker — but it must be enforced deliberately.
How to Pitch It (Stakeholders)
For Executives:
"This bundle adds zero-maintenance observability to our CLI workflows, reducing debugging time by 30%+ and ensuring compliance with audit requirements. As of v1.11.0 it can also capture command output on demand, so when a critical migration or nightly job fails in production, we can see who ran it, when, and exactly what it printed — without reproducing the failure. It’s opt-in and scoped, so we control what gets stored. A 2-hour setup for a 10x improvement in operational visibility, with no ongoing costs."
For Engineers:
*"The Command Logger Bundle lets us log all Symfony commands with one attribute (#[CommandLogger]) or via config. It captures:
- Execution time (spot slow commands),
- Arguments (debug inputs),
- Errors (automate failure tracking),
- Audit trails (who ran what),
- Command output (opt-in, via a flag — viewable with
command-logger:show).
Output capture is off by default and gated behind an explicit opt-in flag, so enable it per command rather than globally — it will grow your log table and can persist secrets if a command echoes them. No database schema changes—just install, configure, and start debugging. Works with Symfony 7/8 and Doctrine 3, and supports wildcards for bulk logging (e.g., make:*). The command-logger:show CLI gives us a built-in way to query logs, and purging is automatic or manual."*
For Developers:
"If you write CLI commands, this bundle automatically logs them—no extra code. Need to debug a failing cron job? Run bin/console command-logger:show --error to see the last 10 failures. Want to track performance? Filter by execution time. Turn on output capture for a specific command and command-logger:show will replay what it printed too — no need to re-run a destructive job just to read its error message. It’s like tail -f for commands, but persistent and queryable."