8000 Reword · symfony/symfony-docs@1c33f40 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c33f40

Browse files
committed
Reword
1 parent 73f1eb4 commit 1c33f40

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

logging.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@ To log a message, inject the default logger in your controller or service::
3232
$logger->info('I just got the logger');
3333
$logger->error('An error occurred');
3434

35-
// log messages can also contain placeholders (wrap the placeholder name with braces)
36-
// these placeholders are useful for logging tools, which can aggregate log messages
37-
// that are the same except for some variable values inside them, for translation
38-
// systems in order to create localized messages, and for security because escaping
39-
// can then be done by the implementation in a context-aware fashion
35+
// log messages can also contain placeholders, which are variable names
36+
// wrapped in braces whose values are passed as the second argument
4037
$logger->debug('User {userId} has logged in', [
4138
'userId' => $this->getUserId(),
4239
]);
@@ -49,6 +46,14 @@ To log a message, inject the default logger in your controller or service::
4946
// ...
5047
}
5148

49+
Adding placeholders to log messages is recommended because:
50+
51+
* It's easier to check log messages because many logging tools group log messages
52+
that are the same except for some variable values inside them;
53+
* It's much easier to translate those log messages;
54+
* It's better for security, because escaping can then be done by the
55+
implementation in a context-aware fashion.
56+
5257
The ``logger`` service has different methods for different logging levels/priorities.
5358
See `LoggerInterface`_ for a list of all of the methods on the logger.
5459

0 commit comments

Comments
 (0)
0