minhyung/monolog-openobserve

Monolog handler for OpenObserve

Maintainers

Package info

github.com/overworks/monolog-openobserve

pkg:composer/minhyung/monolog-openobserve

Transparency log

Statistics

Installs: 1 738

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.2.0 2026-07-21 07:41 UTC

This package is auto-updated.

Last update: 2026-07-21 07:52:16 UTC


README

CI Latest Version PHP Version Total Downloads License

Monolog handler for OpenObserve

Requirements

  • PHP 8.3 or later
  • the curl extension
  • Monolog 3

Installation

composer require minhyung/monolog-openobserve

Usage

use Minhyung\Monolog\OpenObserveHandler;
use Monolog\Logger;

$handler = new OpenObserveHandler(
	host: 'http://localhost:5080',
	organizationId: 'default',
	streamName: 'monolog',
	username: 'admin@yourdomain.com',
	password: 'yourpassword',
);

$logger = new Logger('app');
$logger->pushHandler($handler);

$logger->info('Hello OpenObserve!', ['foo' => 'bar']);

Handling failures

By default the handler throws when OpenObserve cannot be reached or rejects the request, including on an authentication failure such as 401. Set ignoreFailure: true to swallow those errors so that a logging problem never breaks the application:

$handler = new OpenObserveHandler(
	host: 'http://localhost:5080',
	organizationId: 'default',
	streamName: 'monolog',
	username: 'admin@yourdomain.com',
	password: 'yourpassword',
	ignoreFailure: true,
);

Swallowed failures disappear silently. To keep a record of them, pass a fallbackLogger — any PSR-3 logger — and every ignored failure is reported to it at error level, with the original exception under the exception context key:

use Monolog\Handler\ErrorLogHandler;

$handler = new OpenObserveHandler(
	host: 'http://localhost:5080',
	organizationId: 'default',
	streamName: 'monolog',
	username: 'admin@yourdomain.com',
	password: 'yourpassword',
	ignoreFailure: true,
	fallbackLogger: new Logger('openobserve', [new ErrorLogHandler()]),
);

The fallback logger must not write back to this handler, as that would recurse. It is only consulted while ignoreFailure is on; when the handler rethrows, the caller already sees the exception.