Search
Enter at least two characters without personal information.

    LibraryArticles & FAQ Your projectRequest a quote
    LanguageEN
    Practical guides

    Log errors without exposing sensitive data

    Logs should help explain and resolve a situation. Recording every request detail creates volume and can copy information that should not leave its original workflow.

    Go to the method

    Review of a diagnostic screen and notebook
    AI-generated illustration

    Start with questions the logs should answer

    List operational questions: is a form failing, is a process interrupted, has a backup been tested? Define the event, component, time and an appropriate correlation identifier. Avoid messages that collect text without helping identify an action.

    Prepare synthetic examples of success, refusal and failure. An expected refusal should be distinguishable from an outage. Event names and levels should help the owner decide whether to investigate or monitor a trend.

    Connect events from one interaction with a controlled diagnostic identifier without copying a session token. Fictitious example: form.saved and mail.failed both carry DEMO-REQ-21. The first describes saving, the second an email sending failure; neither should erase the meaning of the other. Also distinguish event time from collection time when processing is deferred.

    Visitor-supplied values remain untrusted data in logs. Encode carriage returns CR, line feeds LF and separators for the chosen format so that a field cannot fabricate another entry. Structured JSON does not automatically remove secrets: allowed fields, encoding and size limits are still necessary. Inspect the actual output using fictitious markers, never real passwords.

    Scroll the table horizontally to read every column. With a keyboard, focus the table area and use the arrow keys.

    Fictitious example: connect events without confusing their outcomes
    Retained signalLimited interpretationCheck to perform
    form.saved with DEMO-REQ-21The saving step succeeded.Check the stored result without inferring email delivery.
    mail.failed with DEMO-REQ-21A sending step failed for the same interaction.Start the appropriate follow-up without assuming the enquiry was lost.
    Event time and collection timeThey describe two potentially different moments.Retain time zone and source; do not reconstruct order only from line arrival.
    External value containing CR or LFIt remains a field rather than a new event.Check encoding, size and absence of secrets in the actual output.
    • OWASP : Logging

      Consulted on 22 October 2026; interaction identifiers, separate timestamps, excluded data and prevention of log injection.

    Minimise recorded information

    OWASP discusses data that should be excluded from logs, including passwords, access tokens and sensitive information. Review messages produced by your code as well as plugins, proxies and monitoring services.

    Use an allowlist of fields instead of copying an entire request. A diagnostic identifier may suffice where a full enquiry message would be excessive. Test with synthetic markers, then search outputs for those markers to detect unintended collection.

    Scroll the table horizontally to read every column. With a keyboard, focus the table area and use the arrow keys.

    Choose what enters a log
    Situation or settingWhat it meansUseful check
    Operation failedTechnical reference, time, failure category and useful status.Find the incident without copying the visitor’s private message.
    AuthenticationOutcome and a correlation reference suited to the purpose.Exclude passwords, access tokens and usable session identifiers.
    Visitor inputError category rather than full content where sufficient.Handle line breaks and other characters that could forge a log entry.

    Manage access, retention and volume

    Document who can read logs and why. Confirm they are not served from a public address or made accessible by sharing tools. A diagnostic export needs the same access review as primary storage.

    Choose retention according to the actual need and applicable context rather than copying another service’s duration. Arrange rotation, volume limits and deletion. A repeated failure should not fill a disk through unlimited logging.

    Test the path from signal to action

    Trigger a controlled failure in a test environment. Check the log, alert delivery, recipient and response procedure. An alert sent to an inbox no one checks does not form an operational process.

    Group repetitions and follow signals that support decisions. After an incident, review what was missing and what was unnecessarily exposed. A useful deliverable connects an event with minimum data, an owner and an action.

    Primary documentation : OWASP : Logging Cheat Sheet.

    Limit disclosure of a page’s path and parameters to linked websites.

    Synthetic case: an external link starts from a URL containing a fictitious case identifier. Observe the Referer header on a test destination under the selected policy. Also remove sensitive information from source URLs: limiting referrer data does not erase browser history or previously created logs.

    • Requests disclose only intended referrer information; no real personal identifier is used in the check.
    • MDN Referrer-Policy

      Reference for controlling referrer information included in outgoing browser requests.

    Reference documents

    Content updated on

    Documented reference points for this topic

    Documented reference points for this topic
    ReferenceValue or syntaxScope
    RFC 3339 · Date-time
    2026-10-22T09:00:00+02:00The explicit offset relates local time to UTC; this example is not an appointment.

    Dates indicate when references were consulted. These facts are neither a site audit nor an overall compliance statement.

    Acceptance matrix to adapt to your project

    These proposed checks use synthetic cases. Decide the required behaviour with the team, record the result and assign unresolved gaps before release.

    Scroll the table horizontally to read every column. With a keyboard, focus the table area and use the arrow keys.

    Test cases, expected outcomes and useful evidence
    CaseExpected outcomeEvidence to retain
    Known functional errorThe event explains the outcome and identifies the synthetic request.Synthetic event, timestamp and correlation identifier found in the intended log destinations.
    Synthetic sensitive markerThe marker is absent from fields that should exclude it.Search across every test log destination, including forwarded and archived copies.
    Text containing a newlineThe field cannot manufacture an apparently valid extra event.Received value and the form actually recorded in the destination.
    Unavailable logsApplication behaviour is understood and lost observability can be detected.Application result and observations made while log collection is interrupted.

    Frequently asked questions

    Should enquiry text be logged for diagnosis?

    Not automatically. Identify minimum diagnostic fields and test with synthetic data first. A complete enquiry may be unnecessary for analysing a technical status.

    Does a monitoring tool replace an owner?

    No. It collects or sends a signal, but someone still needs to examine it using an agreed procedure. Test the entire chain with a controlled incident and verify the expected result.