Redactor

Logger runs every log context array through this before writing — a stray password or api_key key in whatever you pass to $logger->info('...', $context) never reaches disk in plaintext.

Method

Redactor::redact(array $data, array $sensitiveKeys = [
    'password', 'secret', 'token', 'api_key', 'apikey', 'authorization',
    'private_key', 'credit_card', 'card_number', 'cvv', 'ssn',
]): array
Redactor::redact([
    'email' => 'marshal@example.com',
    'password' => 'hunter2',
    'meta' => ['api_key' => 'sk-abc123'],
]);
// [
//     'email' => 'marshal@example.com',
//     'password' => '[REDACTED]',
//     'meta' => ['api_key' => '[REDACTED]'],
// ]

Recurses into nested arrays. Key matching is case- and separator-insensitive by substring — X-Api-Key, api_key, and openai_api_key all match the default api_key entry. Pass your own $sensitiveKeys to redact additional app-specific fields.

Next steps

  • Logger — the main consumer, applied automatically to every log context.