pablo1gustavo/monolog-seq

Integrates Monolog with Seq using HTTP ingestion, enabling structured event logging to a centralized Seq server for enhanced log management.

1.0.1 2025-03-03 00:06 UTC

This package is auto-updated.

Last update: 2025-05-01 00:17:59 UTC


README

Integrates PHP Monolog with Seq using HTTP ingestion, enabling structured event logging to a centralized Seq server for enhanced log management.

Installation

Install the latest version with

composer require pablo1gustavo/monolog-seq

Usage

This package automatically sets the CLEF request keys, including @t, @m, @mt, @l, and @x, ensuring seamless structured logging.

For more detailed usage instructions, refer to the official Seq documentation.

Usage (Vanilla PHP)

You can find an example in example.php.

$seqUrl = "http://localhost:5341/api/events/raw";
$seqApiKey = "H16XK1wLgC0LDsen5fwA";

$logger = new Logger('seq');
$logger->pushHandler(new SeqHandler($seqUrl, $seqApiKey));

$logger->critical('error', ['excepasdtion' => new Exception('error')]);
$logger->warning('warn message', ['abc' => "123", 'def' => [1,2,3]]); 
$logger->info("hello my name is {name}", ['name' => 'pablo']);
$logger->debug("debug message", ['date' => new DateTime("2002-01-13")]);
$logger->emergency("teste");

Usage (Laravel)

Laravel allows you to configure custom Monolog handlers, such as this package, within its logging configuration file.

For step-by-step instructions, refer to the Laravel Logging - Creating Monolog Handler Channels documentation.

Example:

        'seq' => [
            'driver' => 'monolog',
            'level' => env('LOG_LEVEL', 'debug'),
            'handler' => \Pablo1Gustavo\MonologSeq\Handler\SeqHandler::class,
            'formatter' => \Pablo1Gustavo\MonologSeq\Formatter\SeqJsonFormatter::class,
            'with' => [
                'url' => env('SEQ_URL'),
                'apiKey' => env('SEQ_API_KEY'),
            ],
        ]