Last active
March 8, 2019 19:15
-
-
Save Shelob9/15cbf9c6168b57ad170bb939a61f829c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.