mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-25 23:55:56 +03:00
[GH-ISSUE #2018] Strip down data of a record context marked by SensitiveParameter #863
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#863
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 @theofidry on GitHub (Jan 20, 2026).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/2018
Context
When logging, values passed as part of the record context may contain PHP objects that are normalized by a
Monolog\Formatter\FormatterInterface:Problem
Consider an object like this:
Since PHP 8.2,
#[SensitiveParameter]preventsUpdateUser::$mySecretUrlfrom appearing in stack traces. However, when such an object is passed as part of a log record context, this attribute is not respected and the sensitive value is still written to the logs.Proposal
Formatters could leverage
#[SensitiveParameter]to automatically redact sensitive properties during normalization.Based on https://github.com/symfony/symfony/pull/46183, this behaviour may not always be desired, so it could be implemented behind a configuration flag. That said, I would argue that redacting by default is the safer choice—frameworks like Symfony could then disable it in dev/debug mode if needed.
Additionally, since users often implement custom formatters, it would be helpful to expose this functionality in a reusable way.