Skip to content

Instantly share code, notes, and snippets.

@nuryagdym
Created September 8, 2021 06:26
Show Gist options
  • Save nuryagdym/4f9ade8ceabad674debc08fedafffb62 to your computer and use it in GitHub Desktop.
Save nuryagdym/4f9ade8ceabad674debc08fedafffb62 to your computer and use it in GitHub Desktop.
Laravel Lumen v5.4 Monolog Logger (Graylog Gelf logger) integration
<?php
//bootstrap/app.php:
//...
$app->configureMonologUsing(function ($monolog) use ($app) {
$publisher = new \Gelf\Publisher(new \Gelf\Transport\HttpTransport(env('GRAYLOG_HOST'), env('GRAYLOG_PORT'), env('GRAYLOG_PATH')));
$failureHandler = new \Monolog\Handler\WhatFailureGroupHandler([new \Monolog\Handler\GelfHandler($publisher)]);
$monolog->pushHandler($failureHandler);
//fixes error: A facade root has not been set
return $monolog;
});
//...
return $app;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment