Level 58
To change the error log path and name in Lumen, you can modify the bootstrap/app.php file.
- Open the
bootstrap/app.phpfile in your Lumen project. - Locate the following line of code:
$app->configureMonologUsing(function ($monolog) {
$monolog->pushHandler(new Monolog\Handler\StreamHandler(storage_path('logs/lumen.log'), Monolog\Logger::DEBUG));
});
- Replace
storage_path('logs/lumen.log')with the desired path and filename for your error log. For example, if you want to change it tostorage/logs/error.log, the modified code would be:
$app->configureMonologUsing(function ($monolog) {
$monolog->pushHandler(new Monolog\Handler\StreamHandler(storage_path('logs/error.log'), Monolog\Logger::DEBUG));
});
- Save the changes to the
bootstrap/app.phpfile.
Now, Lumen will use the specified path and filename for the error log. Make sure the directory exists and is writable by the web server.
Note: If you want to change the log level, you can modify Monolog\Logger::DEBUG to the desired log level (e.g., Monolog\Logger::INFO, Monolog\Logger::ERROR, etc.).