[GH-ISSUE #153] Why can't this logger log objects? Why only arrays? #51

Closed
opened 2026-03-04 02:11:41 +03:00 by kerem · 3 comments
Owner

Originally created by @jeffreytgilbert on GitHub (Jan 29, 2013).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/153

FirePHP supports objects. ChromePHP supports objects. In fact, some objects even have toString methods just for this very purpose. So, why can't we send objects to the logs or can we and I'm missing something. It better not be for some silly reason like "saving file space in text logs" or something. I may have to fork this project to integrate that change if there isn't a way to do it natively that I'm missing.

Originally created by @jeffreytgilbert on GitHub (Jan 29, 2013). Original GitHub issue: https://github.com/Seldaek/monolog/issues/153 FirePHP supports objects. ChromePHP supports objects. In fact, some objects even have toString methods just for this very purpose. So, why can't we send objects to the logs or can we and I'm missing something. It better not be for some silly reason like "saving file space in text logs" or something. I may have to fork this project to integrate that change if there isn't a way to do it natively that I'm missing.
kerem closed this issue 2026-03-04 02:11:41 +03:00
Author
Owner

@jeffreytgilbert commented on GitHub (Jan 29, 2013):

Seems like from another message that you can but you have to stuff that object or array into an array... what? Crazy town. I think I'm going to end up having to change this in my adoption, and I find myself not wanting to. 🎱

<!-- gh-comment-id:12820881 --> @jeffreytgilbert commented on GitHub (Jan 29, 2013): Seems like from another message that you can but you have to stuff that object or array into an array... what? Crazy town. I think I'm going to end up having to change this in my adoption, and I find myself not wanting to. :8ball:
Author
Owner

@jeffreytgilbert commented on GitHub (Jan 29, 2013):

Looks like it is able to process objects, and after a workaround, I was able to make the interface super nice for the framework.

NON ISSUE.

<!-- gh-comment-id:12825987 --> @jeffreytgilbert commented on GitHub (Jan 29, 2013): Looks like it is able to process objects, and after a workaround, I was able to make the interface super nice for the framework. NON ISSUE.
Author
Owner

@Seldaek commented on GitHub (Jan 29, 2013):

Not sure what happened here, but yes you can give an object in the context array, as long as it's wrapped in an array. It's probably best anyway to have array('user' => $user) than just an object without contextual information as to what it is meant to be. Especially if you log multiple things.

<!-- gh-comment-id:12834559 --> @Seldaek commented on GitHub (Jan 29, 2013): Not sure what happened here, but yes you can give an object in the context array, as long as it's wrapped in an array. It's probably best anyway to have array('user' => $user) than just an object without contextual information as to what it is meant to be. Especially if you log multiple things.
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#51
No description provided.