Skip to content

Instantly share code, notes, and snippets.

@reedmaniac
Created April 4, 2016 18:45
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save reedmaniac/de0eae0da380fb086b1fd8711acadf83 to your computer and use it in GitHub Desktop.
Save reedmaniac/de0eae0da380fb086b1fd8711acadf83 to your computer and use it in GitHub Desktop.
// 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