23. Logging Do's and Don'ts
Do
- Log security-relevant actions (logins, config changes).
- Use structured logs (
JSONor key-value format). - Rotate and protect log files.
Don't
- Log secrets or sensitive parameters.
- Use
print()for operational logging. - Leave debug logs enabled in production.
✅ Lesson: Logs are a double-edged sword—use them to audit, not to expose.