How to specify a separate file for logging INFO level in Laravel 5.1 and monolog?
Laravel Monolog. Log INFO level to separate file
Asked Answered
Could you clarify a bit? You want levels INFO and lower to one file and higher than INFO to another? Or maybe something else? –
Neuropath
@Neuropath in fact i want to spit my custom logging from system logging in two separate files. Sorry for being unclear. –
Blandish
Ok, now it's even less clear :) You mentioned "custom logging" - which logger are you using? daily, single, errorlog, syslog or something else? And what should be basis for splitting the logs - level? If so, I need to know what levels should go to which file –
Neuropath
@Neuropath thanks for replying. I am using Monolog, which comes with Laravel. the daily one. Basically i am logging with info level. So it would be enough to separate info level from the others, as larval itself doesn't log anything with info level, so it won't spoil my logs. –
Blandish
If you would like add another monolog handler, you may use the application's configureMonologUsing
method. You should place a call to this method in bootstrap/app.php
file right before the $app variable is returned:
$app->configureMonologUsing(function($monolog) {
$monolog->pushHandler(new StreamHandler('path/to/info.log', Logger::INFO, false)); // false value as third argument to disable bubbling up the stack
});
return $app;
that will also log Laravel ERRORS to that file and other laravel stuff, what i want is a separate file or separate logger instance for my custom logs, which i will read with ease later, not being disturbed by laravel warnings and errors. –
Blandish
ok, it's more clear now @DmitriiG. i updated the answer to support only INFO level –
Epidaurus
© 2022 - 2024 — McMap. All rights reserved.