Skip to content

Commit 73f1eb4

Browse files
committed
minor #17977 Add placeholders for dynamic data (alanpoulain)
This PR was merged into the 5.4 branch. Discussion ---------- Add placeholders for dynamic data From `@Crell`'s post: > Symfony's docs team can include a better example that includes a placeholder on the logging page. It doesn't have to be long, just one more example at the top showing how the placeholder works. So here it is 😄 Commits ------- fcc67c9 docs(logging): add placeholders for dynamic data
2 parents cfadf43 + fcc67c9 commit 73f1eb4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

logging.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ 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
40+
$logger->debug('User {userId} has logged in', [
41+
'userId' => $this->getUserId(),
42+
]);
43+
3544
$logger->critical('I left the oven on!', [
3645
// include extra "context" info in your logs
3746
'cause' => 'in_hurry',

0 commit comments

Comments
 (0)