Safeguard
Security Guides•

Which security events should a microservice log?

Log authentication outcomes, authorization failures, validation failures and changes to sensitive objects. Here is a practical event list with fields.

Safeguard Security Team
4 min read

Log events that help you detect abuse and reconstruct an incident: authentication results, authorization failures, input validation failures, changes to sensitive objects, key and token operations and unexpected network failures. Record who, what, when, from where and the outcome, and keep secrets out.

Where the list comes from

The OWASP Logging Cheat Sheet says the level of security monitoring should be set during requirements and design and be proportionate to risk. Its list of events worth logging includes access to sensitive data, encryption activities such as key use or rotation, creation and deletion of system level objects, data import and export, submission of user generated content such as file uploads, deserialization failures, and network connection failures including backend TLS and certificate validation failures. It also mentions requests with an unexpected HTTP verb.

Add to that the classic authentication and authorization events, since they are the first things responders ask about.

A practical event list

CategoryExamples
AuthenticationLogin success and failure, MFA challenge, password or token reset
AuthorizationAccess denied, role or permission change, privilege use
Input handlingValidation failures, rejected uploads, deserialization errors
Data accessReads of sensitive records, exports, bulk downloads
ConfigurationChanges to settings, feature flags, secrets references
CryptographyKey creation, rotation, failed signature or certificate checks
Service to serviceUnexpected caller, failed mutual TLS, unexpected verb or path
LifecycleStartup, shutdown, version, config load result

Fields that make a log line useful

  1. A timestamp in a consistent time zone with synchronized clocks. OWASP lists time synchronization across servers as a requirement.
  2. An event type from a fixed vocabulary.
  3. The actor: user, service identity or token ID, never the token itself.
  4. The target: resource type and identifier.
  5. The outcome: success, failure and a reason code.
  6. The source: IP address or calling service, noting that forwarded headers can be forged; see the first hop in X-Forwarded-For is attacker controlled.
  7. A correlation or trace ID so you can follow a request across services; see correlation ID vs trace ID.

Practical rules

  • Encode and sanitize log data so users cannot inject line breaks or delimiters. OWASP calls for this explicitly, and our guide on log injection covers it.
  • Make sure a failure in logging does not stop the app or leak data, which OWASP also lists.
  • Write to stdout in a structured format and let the platform route it, as twelve-factor suggests; see stdout or files.
  • Decide retention and who can read logs, since they may contain personal data.

Avoid the two extremes

Logging nothing leaves you blind. Logging everything buries signal, costs money and increases the chance you record something sensitive. Start with the table, test it with an incident scenario and add events when you find gaps. A good test: if an account was taken over yesterday, can your logs show when, from where and what it touched?

Quick check

Should I log every request?

Not necessarily in detail. Log security relevant events with enough context, and keep full request bodies out because they often contain sensitive data.

Do I log failed logins or successful ones?

Both. Failures show attacks in progress, and successes after many failures show a likely compromise.

Where should microservice logs go?

The app should write an event stream to stdout, and the platform should collect and route it to storage you control with access limits.

Where Safeguard fits

Safeguard's compliance and evidence automation helps you keep records that show logging and monitoring controls operating, which supports audit conversations without claiming a certification. See the free scan for the code and dependency side.

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.