[GH-ISSUE #573] Logger - Array to String conversion error #197

Closed
opened 2026-03-04 02:13:04 +03:00 by kerem · 2 comments
Owner

Originally created by @Whyounes on GitHub (Jun 7, 2015).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/573

When you try to log an array like:

$logger->info(["item 1", "Item 2"]);

The Logger shouldn't be responsible for converting messages to string, I think this is the Formater job. We should be able to pass any type of object as long as the formater can handle it correctly.

// \Monolog\Logger.php:252
'message' => (string) $message,

am I missing something?

Originally created by @Whyounes on GitHub (Jun 7, 2015). Original GitHub issue: https://github.com/Seldaek/monolog/issues/573 When you try to log an array like: ``` php $logger->info(["item 1", "Item 2"]); ``` The Logger shouldn't be responsible for converting messages to string, I think this is the Formater job. We should be able to pass any type of object as long as the formater can handle it correctly. ``` php // \Monolog\Logger.php:252 'message' => (string) $message, ``` am I missing something?
kerem closed this issue 2026-03-04 02:13:04 +03:00
Author
Owner

@stof commented on GitHub (Jun 7, 2015):

The first argument of ->info MUST be a string. See the phpdoc of the method and the PSR-3 spec. Using the method with anything else is using it in a broken way.

<!-- gh-comment-id:109747800 --> @stof commented on GitHub (Jun 7, 2015): The first argument of `->info` **MUST** be a string. See the phpdoc of the method and the PSR-3 spec. Using the method with anything else is using it in a broken way.
Author
Owner

@Whyounes commented on GitHub (Jun 7, 2015):

I understand, Thanks

<!-- gh-comment-id:109748496 --> @Whyounes commented on GitHub (Jun 7, 2015): I understand, Thanks
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#197
No description provided.