[GH-ISSUE #296] How can I specify which formatter should be used? #97

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

Originally created by @rmuktader on GitHub (Dec 26, 2013).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/296

Hello,

I am trying to incorporate monolog into a non-symfony project. I need to capture the stack trace when an exception is logged.

Thus far it seems that I need to use the NormalizerFormatter instead of the LineFormatter. But I cannot figure out how to do that. Can some please assist? Many thanks in advance.

Originally created by @rmuktader on GitHub (Dec 26, 2013). Original GitHub issue: https://github.com/Seldaek/monolog/issues/296 Hello, I am trying to incorporate monolog into a non-symfony project. I need to capture the stack trace when an exception is logged. Thus far it seems that I need to use the `NormalizerFormatter` instead of the `LineFormatter`. But I cannot figure out how to do that. Can some please assist? Many thanks in advance.
kerem closed this issue 2026-03-04 02:12:10 +03:00
Author
Owner

@Seldaek commented on GitHub (Dec 26, 2013):

You can just call ->setFormatter() on any handler to change it's default formatter. In this case you would need to write your own I think because the normalizer one will just return an array of data so if you output it in a file you'll just get Array as output for every line, not very useful :)

<!-- gh-comment-id:31229944 --> @Seldaek commented on GitHub (Dec 26, 2013): You can just call `->setFormatter()` on any handler to change it's default formatter. In this case you would need to write your own I think because the normalizer one will just return an array of data so if you output it in a file you'll just get `Array` as output for every line, not very useful :)
Author
Owner

@staabm commented on GitHub (Dec 26, 2013):

Sounds like the thing you are searching for is IntrospectionProcessor. I think the issue tracker is not the right place to ask questions...

<!-- gh-comment-id:31229947 --> @staabm commented on GitHub (Dec 26, 2013): Sounds like the thing you are searching for is `IntrospectionProcessor`. I think the issue tracker is not the right place to ask questions...
Author
Owner

@Fleshgrinder commented on GitHub (Mar 16, 2014):

Simply pass the exception as message to the logger, this will call the exception's __toString() and give you a nice formatting including the stack trace.

<!-- gh-comment-id:37758955 --> @Fleshgrinder commented on GitHub (Mar 16, 2014): Simply pass the exception as message to the logger, this will call the exception's __toString() and give you a nice formatting including the stack trace.
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#97
No description provided.