All contributions

Seldaek/monolog

Monolog

A PHP logging library that sends records to files, sockets, inboxes, databases and web services. Symfony and Laravel use it, among others.

Language
PHP
GitHub stars
21,407
Merged changes
1
Project site
seldaek.github.io

What we changed

RedactingFormatter now also hides secrets nested inside array values under sensitive keys, including copies that already reached the message text.

What this work shows

  • Masking sensitive data in logs
  • Depth-limited recursion
  • Monolog processors and formatters
  • Regression tests in PHPUnit
What was broken

A password inside an array reached the log

RedactingFormatter only collected strings to hide. When the value under password was an array, PsrLogMessageProcessor put it into the message as JSON, and the password stayed there in plain text, even though the context key itself was masked.

How we fixed it

Secrets collected at any depth

A new helper, collectSensitiveValue(), walks the value under a sensitive key and collects every string, within the same MAX_DEPTH limit. A new test checks that the password from the array does not appear in the formatter's output.

#2067

Merged change

1 9 September 2026

What it taught us

Redacting secrets in logs has to walk into nested data and catch copies that leaked through another channel. We can find such a leak in someone else's code and close it with a regression test.

More about this technology: PHP

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.