Install with Composer
composer require orisai/monolog-logtail
Get your API token at logtail.com -> sources -> edit.
Example uses symfony/http-client
PSR-18 integration. Install it in order to get example working.
use Monolog\Logger;
use Orisai\MonologLogtail\LogtailClient;
use Orisai\MonologLogtail\LogtailHandler;
use Symfony\Component\HttpClient\Psr18Client;
$logger = new Logger();
$token = '<YOUR_LOGTAIL_TOKEN>';
// Symfony PSR-18 client is just an example, use any PSR-18 client you like
$client = $requestFactory = $streamFactory = new Psr18Client();
$logger->pushHandler(
new LogtailHandler(
new LogtailClient($token, $client, $requestFactory, $streamFactory)
),
);
Example configuration for Nette framework
Given example is for orisai/nette-monolog, other integrations should work similarly.
PSR-18 client must be registered as a service, e.g. from orisai/nette-http-client.
orisai.monolog:
handlers:
logtail:
service: Orisai\MonologLogtail\LogtailHandler(
Orisai\MonologLogtail\LogtailClient(%logtail.token%)
)
parameters:
logtail:
token: <YOUR_LOGTAIL_TOKEN>