Symfony logs in a live view, context as JSON
To stop tailing var/log/dev.log, add one socket handler to your Symfony Monolog config with the monolog.formatter.json formatter and point it at 127.0.0.1:9913. Every log record then appears live in Buggregator, with its channel, level, message and context as formatted JSON.
Steps
1. Add a socket handler for dev
Put the handler in config/packages/dev/monolog.php. If that file already configures handlers, add the socket handler to the existing chain instead of replacing it. The monolog.formatter.json formatter is required: without it, Buggregator cannot parse the log records.
<?php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
use Symfony\Config\MonologConfig;
return static function (MonologConfig $monologConfig): void {
$monologConfig
->handler('socket')
->level('debug')
->formatter('monolog.formatter.json')
->type('socket')
->connectionString(env('MONOLOG_SOCKET_HOST'));
};2. Set the address
Add the Buggregator address to your .env. In Docker Compose, replace 127.0.0.1 with the Buggregator service name, for example buggregator:9913.
MONOLOG_SOCKET_HOST=127.0.0.1:99133. Open the UI
Open http://127.0.0.1:8000 and use your app. New records appear as they are written. Each one shows the channel (app, security, database and so on), one of the 8 PSR-3 levels, the message, the context and extra fields as JSON. Search finds records by message, channel or level.
4. See where a record came from
When a record has a source key in its context, Buggregator shows the file, line and function that wrote it.
Why it works
Monolog's socket handler writes each record to a TCP address instead of a file. Buggregator listens on port 9913 and reads records in Monolog's JSON format. Logs from workers and other containers can go to the same address, so you see them next to your exceptions and dumps.
Related tips
- Logs
Laravel logs from web, queue and cron in one live view
Add a socket channel to config/logging.php and set LOG_CHANNEL=socket. Laravel logs from requests, queue workers and cron jobs appear live in Buggregator.
- Dumps
dump() without breaking your page or JSON response
Send Symfony VarDumper output to Buggregator with two env vars. dump() stops landing in your HTML or JSON and shows the file and line it came from.
- Dumps
Send ray() calls to a free local viewer
Set RAY_HOST and RAY_PORT in your Laravel .env. Your ray() calls, queries, jobs and mails show up in Buggregator, free and MIT licensed.
Checked on with Buggregator v2.8.0