Skip to content

Logging

All applications developed at DIT must implement consistent, structured, and machine-readable logging practices. Logging is a critical component of observability and plays a central role in debugging, monitoring, auditing, and incident response.

DIT requires that all logs be emitted in JSON format.

JSON logs ensure:

  • full machine readability
  • compatibility with log aggregation systems
  • seamless parsing by OpenTelemetry pipelines
  • consistent structure across all applications
  • improved filtering, querying, and indexing capability

Plain-text, ad-hoc, or non-structured logs are prohibited in production environments.

JSON Logging Requirements

  • Logs must be emitted as valid JSON objects, not strings containing JSON-like text.

  • Log entries must include at minimum:

    • timestamp (ISO 8601 format)
    • log level (info, warn, error, etc.)
    • message
    • service/application name
    • environment (dev, staging, prod)
    • request or correlation ID (when applicable)
  • Sensitive information (passwords, tokens, PII) must never be logged.

  • Multi-line logs must be avoided; each log entry must be a single self-contained JSON object.

  • Logs must not contain circular or unserializable fields.

Example:

json
{
  "timestamp": "2025-01-01T10:15:23.456Z",
  "level": "info",
  "service": "payment-api",
  "environment": "production",
  "message": "Payment request processed successfully",
  "requestId": "a52c3e85-94cd-4cd8-bf67-3a6c83c9b0c0",
  "durationMs": 152
}