Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aligajani's avatar

Anyone figured out logging using Laravel Vapor?

Papertrail works on local and never when deployed to Vapor.

'stack' => [
            'driver' => 'stack',
            'channels' => ['papertrail', 'bugsnag'],
        ],
0 likes
7 replies
aligajani's avatar
aligajani
OP
Best Answer
Level 7

Okay I found the solution in case anyone runs into it after me.

Here's my logging.php configuration. Note stderr.

<?php

use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Log Channel
    |--------------------------------------------------------------------------
    |
    | This option defines the default log channel that gets used when writing
    | messages to the logs. The name specified in this option should match
    | one of the channels defined in the "channels" configuration array.
    |
    */

    'default' => env('LOG_CHANNEL', 'stack'),

    /*
    |--------------------------------------------------------------------------
    | Log Channels
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log channels for your application. Out of
    | the box, Laravel uses the Monolog PHP logging library. This gives
    | you a variety of powerful log handlers / formatters to utilize.
    |
    | Available Drivers: "single", "daily", "slack", "syslog",
    |                    "errorlog", "monolog",
    |                    "custom", "stack"
    |
    */

    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['vapor', 'bugsnag'],
            'ignore_exceptions' => false,
        ],

        'bugsnag' => [
            'driver' => 'bugsnag',
        ],

        'vapor' => [
            'driver' => 'stack',
            'channels' => ['stderr', 'papertrail'],
            'ignore_exceptions' => false,
        ],

        'single' => [
            'driver' => 'single',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
        ],

        'daily' => [
            'driver' => 'daily',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
            'days' => 14,
        ],

        'slack' => [
            'driver' => 'slack',
            'url' => env('LOG_SLACK_WEBHOOK_URL'),
            'username' => 'Laravel Log',
            'emoji' => ':boom:',
            'level' => 'critical',
        ],

        'papertrail' => [
            'driver' => 'monolog',
            'level' => 'debug',
            'handler' => SyslogUdpHandler::class,
            'handler_with' => [
                'host' => env('PAPERTRAIL_URL'),
                'port' => env('PAPERTRAIL_PORT'),
            ],
        ],

        'stderr' => [
            'driver' => 'monolog',
            'handler' => StreamHandler::class,
            'formatter' => env('LOG_STDERR_FORMATTER', "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"),
            'with' => [
                'stream' => 'php://stderr',
            ],
        ],

        'syslog' => [
            'driver' => 'syslog',
            'level' => 'debug',
        ],

        'errorlog' => [
            'driver' => 'errorlog',
            'level' => 'debug',
        ],

        'null' => [
            'driver' => 'monolog',
            'handler' => NullHandler::class,
        ],
    ],

];
booni3's avatar

Did this get paper working on vapor? I have tried the same but no luck

themsaid's avatar

Papertrail won't work. Use Bugsnag or Flare.

1 like
austenc's avatar

Yeah.. this is currently a blocker for our company too. We have an app that allows our admins to search logs directly from within the app, so I don't see a strategy for this to work on vapor.

roberttolton's avatar

Just to add (I arrived here after a Google Search), Papetrail now works fine with Laravel Vapor.

Here's my logging.php

        'papertrail' => [
            'driver' => 'monolog',
            'level' => env('LOG_LEVEL', 'debug'),
            'handler' => SyslogUdpHandler::class,
            'handler_with' => [
                'host' => env('PAPERTRAIL_URL'),
                'port' => env('PAPERTRAIL_PORT'),
                'ident' => \Illuminate\Support\Str::slug(env('APP_NAME')),
            ],
        ],

The ident helps me give something to filter by in Papertrail, rather than the rotating IP Address of AWS Lambda functions.

Though BugSnag is not collecting failed jobs right now, so thinking of adding calls into the failed() methods, either at job-level or global if possible.

2 likes

Please or to participate in this conversation.