OOmnistu

Blog / Engineering Playbooks

Engineering Playbooks

Application logging: what to record, what never to put in logs

Choose useful application security events to log while keeping credentials, tokens and sensitive payment data out of logs.

OOmnistu
Reviewed 2026-11-16 · 2 min read

Logs help you debug problems and notice attacks. OWASP's Logging Cheat Sheet (https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html) focuses on application logging, especially security logging. It says many systems enable web server and database logs, but custom application event logging is often missing, disabled or poorly configured, and that application logs give much more insight than infrastructure logs alone.

Why log

OWASP says application logging should be included for security events, and that logs serve operational uses (debugging, baselines, business process monitoring) and security uses.

What to log

OWASP says what to log should be proportionate to risk and decided in design, and warns that a blind checklist can create "alarm fog" where real problems go undetected. Where possible it recommends logging, among others:

What to keep out

OWASP says to never log data unless it is legally sanctioned. It lists items that should usually not be recorded directly but removed, masked, sanitized, hashed or encrypted: source code, session ID values, access tokens, sensitive personal data, passwords, database connection strings, encryption keys, bank account or card data, commercially sensitive information, and information a user has not consented to or has opted out of. It suggests de-identification techniques where a person's identity is not needed. What is legal to log depends on your jurisdiction; ask qualified counsel. We have not researched Indian rules.

Protect the logs

OWASP describes log injection: if untrusted data is written into a log message, an attacker may be able to add a fake entry, for example with line-break characters. OWASP recommends sanitizing event data, including line breaks and delimiters, and encoding it correctly for the output format. Our practical suggestion is bounded structured logging with a suitable encoder. JSON-shaped text alone does not prevent injection if values are concatenated unsafely.

Questions for your developer

  1. Which security events do we log today?
  2. Do any logs contain passwords, tokens, session IDs or personal data?
  3. Are logs structured, and is user input sanitized before logging?
  4. Who reads logs, and how long are they kept (confirm retention with counsel)?

Limits

We did not read OWASP's sections on event attributes, network architecture, retention or log integrity in detail. This is awareness material, not a compliance assurance.

By Omnistu.

Sources

Previous
Login and authentication basics: what OWASP's Authentication Cheat Sheet recommends