-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert all log messages to PSR-3 format with placeholders #15753
Comments
@hason we must use "old PHP", so the new code would be instead: $this->logger->info(
'Matched route "{route}".',
array('route' => isset($parameters['_route']) ? $parameters['_route'] : 'n/a')
); |
+1 for Javier. This would turn into BC breaks, so I suggest thinking about this great idea for the I'm 👍 on this 😄 |
@javiereguiluz @Pierstoval I've used the new syntax for its brevity. It is used even in the |
Thinking out loud: This semantic could also be used to highlight the variable parts of a log message when rendering the log in the Symfony Profiler. |
@derrabus highlighting log messages is on my TODO list for the profiler. Now that it's been merged, I'll think about it again! |
My point is: Highlighting is hard, if you just have plain text messages, like when composing the messages with But if you get a template of the log message with variables to fill in, highlighting the variable part would probably improve the readability. |
This PR was merged into the 3.1-dev branch. Discussion ---------- Add placeholders into log messages | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #15753 | License | MIT | Doc PR | Commits ------- c92fcdb Added placeholders to all log messages instead of hardcoded values
May be it's too late to discuss about this PR / issue but I'm against it. I really don't see the value added by this (all stuff related into the PSR + Monolog). My point of view: It's very useful for message with a level superior to the level that trigger the cross finger (ie warning / error or more). But for others (debug / info) errors it's IMHO useless. It's useless because there is no need to aggregate log message like More over, without code it's not possible to strtr notice / info / debug message but to let error+ message. Could we consider re-opening this this ? |
… PSR-3 (ged15) This PR was submitted for the master branch but it was merged into the 2.x branch instead (closes #173). Discussion ---------- ability to configure whether messages should be formatted as PSR-3 This PR symfony/symfony#17166 (reasons described in symfony/symfony#15753) has changed the way messages are logged in Symfony. Now log messages contain placeholders (see https://github.com/symfony/symfony-standard/issues/981). While this could be a useful feature, IMO by default in SE messages should be preformatted. This PR introduces a new optional config option that makes the messages be preformatted by default but this behaviour can also be disabled. Commits ------- 6c8a44b ability to configure whether messages should be formatted as PSR-3 44f3daf minor #179 removed obsolete code (fabpot) 7d28c5a Merge branch '2.x' b6baaaf Merge branch '2.x' 57b33d6 removed obsolete code a45682c updated CHANGELOG bcbf4c5 fixed tests 079c3d1 feature #170 remove class parameters (avant1) 6398efc remove class parameters 885da32 added a CHANGELOG d8b3f8a feature #169 Deprecate the NotFoundActivationStrategy class (BPScott) b77bdf0 Deprecate the NotFoundActivationStrategy class ce169ee bumped version to 3.x
It should be used for logging context instead of
sprintf
.Before:
After:
It is still possible to log human-readable messages with PsrLogMessageProcessor, which can be activated on a per-handler basis.
This can be really useful for subsequent processing in logfile monitoring systems as it makes it easier to identify similar messages.
The text was updated successfully, but these errors were encountered: