Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Fred Muya:
Configuring Custom Logging in Laravel 5
May 20, 2015 @ 13:22:36

Fred Muya has posted a guide to his site today showing you how to configure custom logging in your Laravel 5 application. He replaces the default logging methods with an injected Monolog instance.

I recently started working on a Laravel 5 project, and I’d like to share how I set up my custom file logging. I pooled the information below from several sources (acknowledged at the bottom of the article).

He walks through each step you'll need to configure the logging:

  • Overriding the bootstrap ConfigureLogging class (including the code needed)
  • Updating your composer.json to change up the PSR-4 autoloading
  • Modifying the Kernel.php file to update the constructor for the bootstrap (both HTTP and Console)

With these changes in place you can then use the normal "Log" handling Laravel provides and the magic will all happen behind the scenes. He includes two examples of this, one with a simple log string and another with something a bit more complex (and the resulting log output).

tagged: custom logging monolog laravel5 tutorial bootstrap configure

Link: https://blog.muya.co.ke/configure-custom-logging-in-laravel-5/


Trending Topics: