Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Windows Tipps & SecurityWindows-Update beschädigt wichtige Datenrettungsfunktion(22.09.2026 um 09:04 Uhr)
Sichere ProgrammierungBuilding an Accessible Ecommerce Product Page with WCAG 2.2(22.09.2026 um 03:39 Uhr)
Sichere ProgrammierungGet Your Website Protected in 10 Minutes with SafeLine WAF(22.09.2026 um 08:42 Uhr)
Sichere ProgrammierungIntroduction to SPRINGBOOT(22.09.2026 um 08:42 Uhr)
Windows Tipps & SecurityWindows-Update beschädigt wichtige Datenrettungsfunktion(22.09.2026 um 09:04 Uhr)
Sichere ProgrammierungBuilding an Accessible Ecommerce Product Page with WCAG 2.2(22.09.2026 um 03:39 Uhr)
Sichere ProgrammierungGet Your Website Protected in 10 Minutes with SafeLine WAF(22.09.2026 um 08:42 Uhr)
Sichere ProgrammierungIntroduction to SPRINGBOOT(22.09.2026 um 08:42 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

A Developer’s Guide to the Command Logger Bundle for Symfony

For when you can’t access log files, but you can see the database. Ever been in a situation where a command fails on production, but you don’t have access to the server’s log files? All you can do is connect to the database. For fast debu…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

For when you can’t access log files, but you can see the database.




Ever been in a situation where a command fails on production, but you don’t have access to the server’s log files? All you can do is connect to the database. For fast debugging, you don’t need to see every line of output; you just need to answer three simple questions:




  • Did my command run?

  • When did it run?

  • Did it complete successfully or did it fail?



This is the exact scenario the Command Logger Bundle was built for. It’s a purpose-built solution that provides a robust, database-backed audit trail for your console commands, giving you the critical visibility you need, right where you can see it.

What It Does



This bundle automatically captures metadata about your command executions and stores it in a dedicated command_log database table. For each execution, it records:




  • The command’s name

  • The arguments it was run with (in JSON format)

  • The start and end times

  • The final exit code

  • Any error messages

  • A unique executionToken for tracking




A Note on Scope: Fast Auditing, Not Output Logging




It’s important to note that this bundle is designed for fast debugging and auditing. Its primary goal is to track when a command has been executed and if its outcome was OK or not.



It does not capture the command’s output (e.g., messages written to the console or logs generated by Monolog within the command). It only logs the metadata about the execution itself.

Installation and Configuration





Getting started is a simple two-step process.





Step 1: Install with Composer



First, add the bundle to your project using Composer:



composer require ayaou/command-logger-bundle



If your project doesn’t use Symfony Flex, you’ll need to manually register the bundle in config/bundles.php:




// config/bundles.php
return [
// ...
Ayaou\CommandLoggerBundle\AyaouCommandLoggerBundle::class => ['all' => true],
];









Step 2: Configure the Bundle [Optional]



Next, create a configuration file at config/packages/command_logger.yaml to control the bundle's behaviour.




# config/packages/command_logger.yaml
command_logger:
# Enable or disable all logging globally. Defaults to true.
enabled: true

# Days after which old logs are automatically deleted.
purge_threshold: 100

# A list of commands to log, especially useful for third-party
# bundles where you cannot add attributes. Wildcards are supported.
commands:
- app:example-command
- app:another-command
- make:*









How to Log Your Commands



You have two ways to specify which commands should be logged.






1. The Attribute Method (Recommended)



For commands within your own project, the easiest method is to use the #[CommandLogger] attribute directly on the command class.




use Ayaou\CommandLoggerBundle\Attribute\CommandLogger;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
// ...

#[AsCommand(name: 'app:example-command')]
#[CommandLogger]
class ExampleCommand extends Command
{
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('Executing example command...');
return Command::SUCCESS;
}
}






That’s it! The bundle will now automatically log every execution of app:example-command.






2. The Configuration Method



If you want to log a command that you cannot modify (for example, a command from a third-party bundle), you can add its name to the commands array in your command_logger.yaml file, as shown in the configuration step.






Viewing and Filtering Logs



Once you have logged some command executions, you can easily view them from your terminal using the built-in command-logger:show command. This is perfect for quickly checking the status of recent jobs.




  • View the latest 10 logs:



bin/console command-logger:show




Filter by command name:




bin/console command-logger:show app:example-command




  • Quickly find failed commands (the primary use case!):



bin/console command-logger:show --error



Use — success to show commands that run successfully.




  • Find a specific log entry by its ID:



bin/console command-logger:show --id=123



The command also supports interactive pagination; simply press Enter to load more entries.






Keeping Your Logs Tidy



A log table can grow quickly. The Command Logger Bundle provides tools to prevent it from getting out of control.






Automatic Purging



The purge_threshold option in your configuration file automatically deletes logs older than the specified number of days. And of course, do not forgot to put this command in a cron job that runs periodically.






Manual Purging



If you need to clean up logs manually, you can run the command-logger:purge command.




  • Purge logs using the configured threshold

    bin/console command-logger:purge


  • Purge logs older than 30 days, overriding the config

    bin/console command-logger:purge --threshold=30







Conclusion



The Command Logger Bundle offers a focused and powerful solution for auditing your Symfony console commands, especially in environments where direct log file access is limited. By providing a persistent, queryable database log with built-in tools for viewing and maintenance, it dramatically improves your ability to debug and monitor your application’s command-line activity.



This bundle is distributed under the MIT Licence. For more information, please visit the official repository.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten A Developer’s Guide to the Command Logger Bundle for Symfony

Thematisch verwandte Begriffe: Developers, Guide, Command, Logger · 6 Treffer

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-55210 | Joplin is an open source note-taking and to-do application that organise…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick