I tried to configure log rotation on Lumen but I'm stuck. I know how to do this with Laravel, but (one more time) I'm lost with Lumen.
I tried to add this in app/bootstrap.php
, because I read it somewhere:
$app->configureMonologUsing(function(Monolog\Logger $monolog) use ($app) {
$monolog->pushHandler(
new \Monolog\Handler\RotatingFileHandler($app->storagePath().'/logs/lumen.log', 5)
);
});
And I can view this error:
Fatal error: Uncaught Error: Call to a member function error() on null in /x/vendor/laravel/lumen-framework/src/Exceptions/Handler.php:36
Stack trace:
#0 /x/app/Exceptions/Handler.php(36): Laravel\Lumen\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#1 /x/vendor/laravel/lumen-framework/src/Concerns/RegistersExceptionHandlers.php(123): App\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 /x/vendor/laravel/lumen-framework/src/Concerns/RegistersExceptionHandlers.php(51): Laravel\Lumen\Application->handleUncaughtException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#3 [internal function]: Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(Object(Error))
#4 {main}
thrown in /x/vendor/laravel/lumen-framework/src/Exceptions/Handler.php on line 36
I don't understand what does it mean, and what I should do.
Does someone has succeeded in rotating log in lumen 5.2?
You forget returning the object, it should be: