Skip to content

[12.x] Skip message serialization when log level is not handled#58475

Merged
taylorotwell merged 2 commits intolaravel:12.xfrom
dxnter:fix/skip-log-serialization-for-unhandled-levels
Jan 23, 2026
Merged

[12.x] Skip message serialization when log level is not handled#58475
taylorotwell merged 2 commits intolaravel:12.xfrom
dxnter:fix/skip-log-serialization-for-unhandled-levels

Conversation

@dxnter
Copy link
Contributor

@dxnter dxnter commented Jan 23, 2026

Fixes #58472

Adds a check in Logger::writeLog() to skip potentially expensive formatMessage() serialization (e.g., var_export(), toJson(), toArray()) when the log level won't be handled by any handler.

This uses Monolog's isHandling() method when available, and falls back to the existing behavior for other PSR-3 implementations.

@taylorotwell taylorotwell merged commit 4af55b2 into laravel:12.x Jan 23, 2026
68 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Large array serialization occurring for log level that is not enabled

2 participants