mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 08:05:53 +03:00
[GH-ISSUE #944] Does NormalizeFormatter->normalize() ever receive anything other than an array? #376
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#376
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rosshettel on GitHub (Mar 14, 2017).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/944
Trying to fix up our app's logging set up, and wanted to set up Exceptions to be formatted nicely in Slack. I'm having trouble understanding how to do so though.
So if I do
$log->error($e);, the Exception gets cast to a string here, which makes sense.Or if I try
$log->error('Exception happened', $e);, I get an error because context is expected to be an array here.But I noticed in NormalizerFormatter that it has a special case to normalize an Exception, which sounds great. But as far as I can tell and with my testing, it will only ever get passed an array - so how do I properly log an exception so that it does so?
@Seldaek commented on GitHub (Mar 17, 2017):
Logging exceptions, as per PSR-3, should be done as
$logger->error('Something something', ['exception' => $e]);Generally speaking, context information should be an array with meaningful keys and their associated data I would say.