Skip to content

Log warnings on php artisan optimize: Request macros already exist #10

@onlime

Description

@onlime

I have integrated bilfeldt/laravel-request-logger in the most standard way in my L11 project (latest Laravel v11.34.2), without any config modifications and only by adding the LogRequestMiddleware to some api routes.

Request logging works fine, but whenever I run php artisan optimize on production, the CorrelationIdServiceProvider (L84-L129) logs these warnings:

Request::getUniqueId() already exists, skipping macro registration.  
Request::getCorrelationId() already exists, skipping macro registration.  
Request::getClientRequestId() already exists, skipping macro registration.  
Request::getUniqueId() already exists, skipping macro registration.  
Request::getCorrelationId() already exists, skipping macro registration.  
Request::getClientRequestId() already exists, skipping macro registration.  

It always logs twice for all 3 macros that it tries to register.
This is a problem for me, as I send out Slack notifications for every log level above WARNING.

Even if I run a optimize:clear right before in my deployment, it happens.

php artisan optimize:clear
php artisan optimize # => 6 warnings fired!

the following are the cause:

php artisan config:cache # => 3 warnings fired!
php artisan route:cache # => 3 warnings fired!

Honestly, I don't know if this is a general problem of some stale caching on optimize, as I don't have any other packages installed that log any warnings when registering any macros.

Would very much appreciate if you could investigate this, as it might fill up other's application logs as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions