PHP code example of aldoginting / papertrail-laravel

1. Go to this page and download the library: Download aldoginting/papertrail-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aldoginting / papertrail-laravel example snippets


$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;
});

'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%',
    ],
],

    protected $middleware = [
        ...
        PapertrailLaravel\Middleware\PapertrailLoggingMiddleware::class,
    ];

$app->middleware([
    ...
    PapertrailLaravel\Middleware\PapertrailLoggingMiddleware::class,
]);