Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\ServiceProvider;
use Monolog\Logger;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\SyslogUdpHandler;
class AppServiceProvider extends ServiceProvider {
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$url = env( 'PAPERTRAIL_URL', '' );
if ( filter_var( $url, FILTER_VALIDATE_URL ) ) {
$output = "%channel%.%level_name%: %message%";
$formatter = new LineFormatter( $output );
$logger = Log::getMonolog();
$syslogHandler = new SyslogUdpHandler( "logs6.papertrailapp.com", env( 'PAPERTRAIL_PORT' ) );
$syslogHandler->setFormatter( $formatter );
$logger->pushHandler( $syslogHandler );
}
}
}
@Ryuske

This comment has been minimized.

Copy link

commented Mar 8, 2019

On line 37, you're not actually using the PAPERTRAIL_URL config value.

Otherwise, thanks for posting this! It was helpful for me getting Papertrail setup on our application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.