This project is a fork of karlomikus/multilog
Easily add multiple Monolog channels to your Laravel or Lumen application.
Via Composer
composer require karlomikus/multilog
Or add the package to your composer file:
"karlomikus/multilog": "2.*"
Next register service provider and facade in your config/app.php
file:
// Service provider
Karlomikus\Multilog\MultilogServiceProvider::class
// Facade (optional)
'Multilog' => Karlomikus\Multilog\Facade::class
With Laravel, you can publish the configuration file with:
php artisan vendor:publish
If you are using Lumen, please copy the example of
configuration file
to your application config
directory. Then add the following line to
bootstrap/app.php
:
$app->configure('multilog');
All your channels are defined in config/multilog.php
file.
By default you have two channels (request and info):
// Request channel
'request' => function ($channel) {
$logger = new Logger($channel);
...
return $logger;
},
// Info channel
'info' => function ($channel) {
$logger = new Logger($channel);
...
return $logger;
}
Using dependency injection:
use Karlomikus\Multilog\Contracts\MultilogInterface;
private $multilog;
public function __construct(MultilogInterface $multilog)
{
$this->multilog = $multilog;
$this->multilog->channel('request')->error('Error here...');
}
Using facade:
Multilog::channel('channel-name')->info('Information here...');
// Channel shorthand is also available
Multilog::c('channel-name')->warning('Warning here...');
If you wanna make sure Multilog is used, you can redirect all Log facade calls to Multilog by adding the following service provider:
// Service provider
Karlomikus\Multilog\LogServiceProvider::class
Then configure the default channel in your config/multilog.php
file:
'defaultChannel' => 'global',
'channels' => [
'request' => function ($channel) {
$logger = new Logger($channel);
...
return $logger;
},
]
- Change configuration format to use closures
- Compatibility with Lumen
- Possibility to redirect
Log
calls to aMultilog
default channel
- Initial release
The MIT License (MIT). Please see License File for more information.