Skip to main content
This content is for SDK V4. For the latest version, see the V5 documentation.
Ditto provides comprehensive logging capabilities to help you monitor, debug, and optimize your applications. The SDK includes a sophisticated logging system with automatic rotation, compression, and configurable retention policies.

Logging Rotation in Ditto

Core System

Ditto uses a custom ditto-rotating-file crate that provides thread-safe rotating file writers with automatic compression.

Rotation Triggers

Files rotate based on two criteria:
  • Size limit: Default 1MB uncompressed (configurable 1MB-1GB)
  • Age limit: Default 24 hours (configurable 1+ hours)

File Management

  • Naming: ditto-logs-YYYY-MM-DD-HH-MM-SS.microseconds.log
  • Compression: Automatic gzip compression when rotated (.log → .log.gz)
  • Retention: Default 15 files maximum (configurable 3-64 files)

Configuration Parameters

Key Features

  • Multi-threaded compression in background
  • Automatic cleanup of oldest files when limit exceeded
  • Runtime reconfiguration without restart
  • Export functionality for diagnostics
  • Crash recovery - compresses leftover uncompressed files on startup

Integration

  • Uses tracing-subscriber with JSON formatting
  • Always logs at DEBUG level to disk (independent of console level)
  • Filtered to prevent recursive logging from the rotation system itself

Disk Usage

The system maintains approximately ~15MB disk usage by default (15 × 1MB compressed files) and handles rotation completely automatically with robust error recovery.