Created
April 4, 2016 18:45
-
-
Save reedmaniac/de0eae0da380fb086b1fd8711acadf83 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
// Put at the top of ./config/app.php | |
// Custom Monolog Configuration - https://laravel.com/docs/5.2/errors#configuration | |
use Monolog\Logger; | |
use Monolog\Handler\StreamHandler; | |
use Illuminate\Mail\TransportManager; | |
$app->configureMonologUsing(function($monolog) use ($app) { | |
// Set bubble to false to keep logs separate and clean | |
$monolog->pushHandler(new StreamHandler(storage_path('logs/laravel.info.log'), Logger::INFO, false)); | |
$monolog->pushHandler(new StreamHandler(storage_path('logs/laravel.debug.log'), Logger::DEBUG, false)); | |
$monolog->pushHandler(new StreamHandler(storage_path('logs/laravel.error.log'), Logger::ERROR, false)); | |
// Send email on error in production | |
if ($app['config']['app']['env'] === 'production') | |
{ | |
$from = $app['config']['mail']['from']; | |
$transport = new TransportManager($app); | |
$mailer = new Swift_Mailer($transport->driver()); | |
$monolog->pushHandler(new Monolog\Handler\SwiftMailerHandler( | |
$mailer, | |
Swift_Message::newInstance('[Log] Error Bookbranch') | |
->setFrom($from['address'], $from['name']) | |
->setTo('paul@reedmaniac.com'), | |
Logger::ERROR, | |
true | |
)); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment