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

wonder95's avatar

Required Steps For Setting Up Papertrial Logging In Laravel

I'm attempting to set up Papertrail logging for our large Laravel app, and I need to confirm all of the required setup steps. Per the docs, I have

  • created the papertrail definition in config/logging.php
        'papertrail' => [
            'driver' => 'monolog',
            'level' => env('LOG_LEVEL', 'debug'),
            'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
            'handler_with' => [
                'host' => env('PAPERTRAIL_URL'),
                'port' => env('PAPERTRAIL_PORT'),
                'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
            ],
            'processors' => [PsrLogMessageProcessor::class],
        ],
    
  • added the PAPERTRAIL_URL, PAPERTRAIL_PORT, and LOG_CHANNEL=papertrail in my .env file.

In looking at the Papertrail docs, it appears that I also need to install remote_sysylog2. However, looking at the Laravel docs (and other blog posts, it appears that I just need to define the papertrail channel and set my .env values, as I have done.

Which is correct? Do I need remote_syslog2?

0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

To set up Papertrail logging in a Laravel application, you generally do not need to install remote_syslog2 if you are using the Monolog library, which is already integrated into Laravel. The steps you have taken are mostly correct, but let's ensure everything is set up properly:

  1. Update config/logging.php:

    You have already added the papertrail channel configuration. Ensure that the SyslogUdpHandler and PsrLogMessageProcessor classes are correctly imported at the top of your logging.php file:

    use Monolog\Handler\SyslogUdpHandler;
    use Monolog\Processor\PsrLogMessageProcessor;
    
  2. Environment Variables:

    Make sure your .env file includes the following variables with the correct values:

    PAPERTRAIL_URL=your-papertrail-url
    PAPERTRAIL_PORT=your-papertrail-port
    LOG_CHANNEL=papertrail
    

    Replace your-papertrail-url and your-papertrail-port with the actual values provided by Papertrail.

  3. Verify Configuration:

    Double-check that your config/logging.php file has the correct configuration for the papertrail channel. Here is a refined version of what it should look like:

    'papertrail' => [
        'driver' => 'monolog',
        'level' => env('LOG_LEVEL', 'debug'),
        'handler' => SyslogUdpHandler::class,
        'handler_with' => [
            'host' => env('PAPERTRAIL_URL'),
            'port' => env('PAPERTRAIL_PORT'),
            'connectionString' => 'tls://' . env('PAPERTRAIL_URL') . ':' . env('PAPERTRAIL_PORT'),
        ],
        'processors' => [PsrLogMessageProcessor::class],
    ],
    
  4. Clear Configuration Cache:

    After making changes to your configuration files, clear the configuration cache to ensure Laravel picks up the new settings:

    php artisan config:cache
    
  5. Testing:

    To test if the logging is working, you can trigger a log entry in your application and check if it appears in your Papertrail dashboard:

    Log::info('This is a test log message for Papertrail.');
    

If you follow these steps, you should be able to log to Papertrail without needing remote_syslog2. The Monolog library handles the UDP logging directly to Papertrail. If you encounter any issues, double-check your environment variables and ensure your server can reach the Papertrail endpoint.

Please or to participate in this conversation.