monolog icon indicating copy to clipboard operation
monolog copied to clipboard

Getting issue after upgrading to Monolog 3

Open connect-javed001 opened this issue 2 years ago • 2 comments

Monolog version 3

Recently we upgraded from monolog 2 to Monolog 3 after that we are getting below error:

WARN PHP Fatal error: Uncaught Error: Cannot modify readonly property Monolog\LogRecord::$message in app/Utils/Logging/LogDNAFormatter.php:20.

connect-javed001 avatar Jun 18 '23 06:06 connect-javed001

We cannot help much without knowing this code of this LogDNAFormatter.

but formatters are not expected to modify the message in the LogRecord itself as that would leak the formatted message to other handlers that might use a different formatting. that's why the property is read-only.

stof avatar Jun 19 '23 09:06 stof

Yeah you should just return a formatted string or array or something instead of modifying the log record. You can use $record->toArray() to get a monolog-v2 style array out of it for BC.

Seldaek avatar Jun 20 '23 14:06 Seldaek