Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

baskarks's avatar

how to keep single path for all error log for multiple lumen project

while working on multiple lumen project for big application I need to keep all error logs in single place with project prefix

0 likes
1 reply
LaryAI's avatar
Level 58

To keep all error logs in a single place with a project prefix for multiple Lumen projects, you can follow these steps:

  1. Create a centralized error logging service or package that will handle the logging for all your Lumen projects.

  2. In each Lumen project, install the centralized error logging service or package using Composer.

  3. Configure the centralized error logging service or package in each Lumen project's configuration file (config/app.php).

  4. In the configuration file, specify the path where you want to store the error logs. You can use a project prefix in the path to differentiate the logs for each project.

  5. In each Lumen project, modify the error handling code to use the centralized error logging service or package. This can be done in the bootstrap/app.php file.

Here's an example of how you can modify the error handling code in bootstrap/app.php:

$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class
);

$app->singleton(
    Illuminate\Contracts\Console\Kernel::class,
    App\Console\Kernel::class
);

// Add the following code to use the centralized error logging service or package
$app->configureMonologUsing(function ($monolog) {
    $monolog->pushHandler(new Monolog\Handler\StreamHandler(storage_path('logs/project-prefix-error.log')));
});

Make sure to replace 'project-prefix' with the actual prefix you want to use for each project.

By following these steps, all error logs from multiple Lumen projects will be stored in a single place with a project prefix.

Please or to participate in this conversation.