aldoginting / papertrail-laravel
Log laravel request to papertrail
Installs: 1 158
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 2
Requires
- monolog/monolog: ~1.12
This package is not auto-updated.
Last update: 2024-12-11 20:53:30 UTC
README
Enable Papertrail Logging on Laravel/Lumen.
Installation
composer require aldoginting/papertrail-laravel *
Usage
If you're using lumen >= 5.6.x, skip this step.
Configure Monolog in bootstrap/app.php:
$app->configureMonologUsing(function ($monolog) { $papertrailHandler = new \PapertrailLaravel\Handler\PapertrailLogHandler({YOUR_PAPERTRAIL_HOST}, {YOUR_PAPERTRAIL_PORT}, {APP_NAME(optional)}); $formatter = new \Monolog\Formatter\LineFormatter('%level_name% REQUEST: %message%'); $papertrailHandler->setFormatter($formatter); $monolog->pushHandler($papertrailHandler); return $monolog; });
For Lumen >= 5.6.x
Add following line to your config/logging.php
channels:
'papertrail' => [ 'driver' => 'monolog', 'handler' => \PapertrailLaravel\Handler\PapertrailLogHandler::class, 'handler_with' => [ 'host' => 'your_papertrail_host', 'port' => 'your_papertrail_port', ], 'formatter' => Monolog\Formatter\LineFormatter::class, 'formatter_with' => [ 'format' => '%level_name% REQUEST: %message%', ], ],
Register Middleware
- Laravel
Register middleware in app/kernel.php.
protected $middleware = [ ... PapertrailLaravel\Middleware\PapertrailLoggingMiddleware::class, ];
- Lumen
Register middleware in bootstrap/app.php.
$app->middleware([ ... PapertrailLaravel\Middleware\PapertrailLoggingMiddleware::class, ]);
Optionals
You can log response by adding PAPERTRAIL_LOG_RESPOSE=true
in your .env
Milestones
- Move response logging flag to somewhere else
- Support custom message format