Skip to content

Instantly share code, notes, and snippets.

@rufhausen
Created May 21, 2015 00:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rufhausen/93c6041b033802e5fda4 to your computer and use it in GitHub Desktop.
Save rufhausen/93c6041b033802e5fda4 to your computer and use it in GitHub Desktop.
Laravel custom logging with MonoLog
<?php namespace App\Services;
/*
*
* Credit and info about adding singleton to bootstrap/app.php on this thread on Laracasts:
* https://laracasts.com/discuss/channels/general-discussion/error-on-overriding-configurelogging-bootstrap-class?page=1#reply-42802
*
*/
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\Bootstrap\ConfigureLogging as BaseConfigureLogging;
use Illuminate\Log\Writer;
use Illuminate\Support\Facades\Log as Log;
use Monolog\Handler\StreamHandler as StreamHandler;
use Monolog\Processor\MemoryPeakUsageProcessor;
use Monolog\Processor\MemoryUsageProcessor;
use Monolog\Processor\WebProcessor;
class ConfigureLogging extends BaseConfigureLogging
{
/**
* Custom Monolog handler that for Logentries.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @param \Illuminate\Log\Writer $log
* @return void
*/
protected function configureHandlers(Application $app, Writer $log)
{
$logger = $log->getMonolog();
$logfile_handler = new StreamHandler(storage_path() . '/logs/laravel.log');
$logger->pushHandler($logfile_handler);
$logger->pushProcessor(new MemoryUsageProcessor);
$logger->pushProcessor(new MemoryPeakUsageProcessor);
$logger->pushProcessor(new WebProcessor);
}
}
Copy link

ghost commented Sep 24, 2015

This will simply change the default path of the laravel logging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment