vendredi 24 novembre 2017

Using multiple log files in Laravel 5 with all levels available

How do I use multiple log files in Laravel, where I want all available levels to be written to the file (current implementations I've seen here talk about different files for different levels. This is not what I want - instead I want different files for different 'categories' e.g. one for the UI, one for jobs etc). I see "laravel.log" is hardcoded in LogServiceProvider, so was thinking I have a few choices:

1/ Create an instance of monologger directly and put into the container, this will mean that I think I will have to use it like $myLogger = App::make('job_logger'); ... $myLogger->info($msg) as I'm working with the native monologger object.

2/ Possibly extend the LogServiceProvider class? This would allow me to set a facade to the extended class, so I could just do JobLog::info($msg)? How would I do this with minimum fuss? I think I'd just need to overwrite the configureSingleHandler function?

I'd imagine this is a common problem in laravel. Is there a more 'Laravel'y method of going about this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire