What Not to Log
You'll learn: How to avoid logging sensitive information, secrets, and noise that compromises security, privacy, or system performance.
The Core Problem
Not everything can or should be logged. While logging helps you debug and monitor systems, careless logging creates security vulnerabilities, privacy violations, and operational headaches. Think of logs like a public bulletin board—you wouldn't pin your bank password or social security number there, even if it's in your "secure" office building.
What Never Belongs in Logs
Sensitive Data and PII
Never log:
- Passwords, API keys, tokens, or cryptographic secrets
- Social security numbers, credit card numbers, or personal identification
- Health records, financial data, or legally protected information
- Full authentication credentials or session tokens
Even if your logs are "secure," they often get copied, backed up, analyzed by third parties, or accessed by more people than you realize. One leaked log file can expose thousands of users.
High-Volume Noise
Avoid logging:
- Every single request in high-traffic systems (use sampling instead)
- Large payloads or binary data
- Repetitive "everything is fine" messages
- Debug statements left active in production
Excessive logging degrades performance, fills storage, and makes finding real problems like searching for a needle in a haystack of needles.
Implementation Details
Don't log:
- Internal system paths or architecture details that help attackers
- Stack traces containing sensitive variable values
- Raw database queries with user input embedded
The Right Approach
Log identifiers (user IDs, transaction IDs) and context (what action, what result), but redact or hash sensitive values. Use structured logging so you can filter and sanitize automatically.
Key Takeaway: Treat logs as potentially public documents—never include passwords, secrets, PII, or excessive noise that compromises security, privacy, or operability.