Safeguard
Security Guides•

Temporary debug logging in a health app: rules before you enable it

Debug logging in production is where sensitive data leaks. Use time limits, scoped targets, an approver and cleanup, with these steps for health apps.

Safeguard Security Team
4 min read

Enable debug logging in a health app production system only for a named reason, a narrow scope, a fixed expiry and an approver, then confirm it is off and the output is deleted. Debug logs tend to capture payloads that normal logs avoid, so treat them as sensitive data until proven otherwise.

Why debug mode is risky

Verbose logging is often added during an outage. A developer turns on request and response logging for one service, finds the problem and forgets to turn it off. For weeks, full payloads flow into the log store, where the usual review and redaction never expected them.

The OWASP Logging Cheat Sheet addresses this directly: temporary debug logs, along with backups and extractions, must not be destroyed before the required retention period, and they also must not be kept beyond that period. In other words, debug output is still log data with rules attached. It also says sensitive items should be removed, masked, hashed or encrypted before logging.

Rules to adopt

  1. A ticket exists that says why debug logging is needed and what question it answers.
  2. The scope is one service, one environment and, where possible, one test account.
  3. An approver other than the requester signs off.
  4. A fixed expiry is set, ideally within hours.
  5. The output goes to a separate, access restricted location.
  6. A named person confirms the setting is reverted and deletes the debug output once it is no longer needed under your retention rule.
  7. The ticket records the dates, the scope and the cleanup.

Safer alternatives first

  • Reproduce in staging with synthetic data. Keep real patient records out of test systems where you can.
  • Add a targeted log line for the specific variable, with a safe identifier, instead of dumping the whole object.
  • Use sampling, such as capturing one in a thousand requests.
  • Use a feature flag that can only be turned on for a test account.

A quick runbook

StepOwnerDone when
Raise ticket with scopeRequesterTicket links the incident
Approve and set expiryApproverExpiry time recorded
Enable on one serviceOn callConfig change in version control
InvestigateRequesterCause found or time up
Revert and deleteOn callConfig reverted, output removed
Review log sampleSecurity ownerNo sensitive fields found

Keeping the config change in version control gives you a timestamped record without extra tools.

Try it yourself

Click through it at your own pace, or open it full screen.

Look at how a policy gate blocks a change that breaks a rule. A check that fails when a debug flag appears in a production config follows the same idea.

Where Safeguard fits

Safeguard provides policies, gates and guardrails for pull requests and compliance and evidence automation. You can use them to hold the review trail for changes like these. The logging rules and approvals are your team's decisions. A free scan is available at gold.safeguard.sh/scan.

Quick check

How long should debug logging stay on?

As short as the investigation allows, usually hours. Set the expiry when you enable it.

Do we have to delete debug logs?

Delete them once your retention rule allows. The OWASP guidance says not to keep them beyond that period.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.