Skip to main content

Laravel logs from web, queue and cron in one live view

Make socket your Laravel log channel: add it to config/logging.php with Monolog's SocketHandler and the JsonFormatter, then set LOG_CHANNEL=socket. Your logs appear live in Buggregator, with the context as formatted JSON, instead of in a file you tail -f.

Steps

1. Add the socket channel

Add the channel to config/logging.php. The JSON formatter is required.

php
// config/logging.php
return [
    // ...
    'channels' => [
        // ...
        'socket' => [
            'driver' => 'monolog',
            'level' => env('LOG_LEVEL', 'debug'),
            'handler' => \Monolog\Handler\SocketHandler::class,
            'formatter' => \Monolog\Formatter\JsonFormatter::class,
            'handler_with' => [
                'connectionString' => env('LOG_SOCKET_URL', '127.0.0.1:9913'),
            ],
        ],
    ],
];

2. Switch your app to it

Set two lines in .env. This sends logs to Buggregator instead of your current channel, for example stack and its files. In Docker Compose, replace 127.0.0.1 with the Buggregator service name, for example buggregator:9913.

dotenv
LOG_CHANNEL=socket
LOG_SOCKET_URL=127.0.0.1:9913

3. Open the UI

Open http://127.0.0.1:8000. New records appear as they are written, each with its channel, level, message and context. Search finds records by message, channel or level.

4. Run your workers as usual

Queue consumers, cron jobs and daemons write logs that are easy to miss in stdout. With the same .env, they log to the same view as your web requests.

Why it works

Monolog's SocketHandler writes each record to a TCP address instead of a file. Buggregator listens on port 9913 and reads the JSON records. Every process that uses the socket channel sends to the same place, so you read them side by side, next to your exceptions and dumps.

Checked on with Buggregator v2.8.0

Setup in 60 seconds

No registration. No account. Start it and point your app at it.

1

Start Buggregator

One file, installed with one command. The web UI opens on port 8000. Prefer containers? Use the Docker tab.

$ curl -fsSL https://raw.githubusercontent.com/buggregator/server/master/scripts/install.sh | sh
$ HTTP_ADDR=127.0.0.1:8000 \
  SMTP_ADDR=127.0.0.1:1025 \
  VAR_DUMPER_ADDR=127.0.0.1:9912 \
  MONOLOG_ADDR=127.0.0.1:9913 \
  PROXY_ADDR=127.0.0.1:8080 \
  ~/.local/bin/buggregator

The script picks the file for your CPU: Intel/AMD or ARM.

One file for Linux, macOS and Windows, about 40 MB. Nothing else to install.

This run line keeps it on this computer. Without the *_ADDR settings it listens on all network interfaces →

Rather not run a script? Download the file yourself →

Runs on Windows, macOS and Linux, on Intel/AMD and ARM.

Prefer not to do it yourself? Your AI agent can set Buggregator up for you →