Logs must not contain sensitive information such as passwords, API tokens, or card data. Attackers with log access can exploit leaked data. Magento logging should use sanitization filters and redact sensitive values before writing to files or monitoring systems.
Logs are often used for debugging and monitoring, but if they contain sensitive data such as passwords, API keys, credit card numbers, or personal details, they become a liability. Attackers who gain access to log files can harvest this data and use it for fraud or account takeover.
Sanitizing logs ensures only safe, useful information is recorded. By redacting or removing sensitive values before writing them, you keep logs helpful for troubleshooting without creating a new source of data leakage. This also supports compliance with privacy regulations like GDPR and PCI DSS.
# Review log files for sensitive data
grep -R "password" var/log
grep -R "token" var/log
grep -R "card" var/log
# Review custom code for logging raw request/response data
// Unsafe logging
$this->logger->info("Login failed for user $email with password $password");
// Safe logging
$this->logger->info("Login failed for user $email");
// Password not included