This content is for SDK V4. For the latest version, see the V5 documentation.
Logging Rotation in Ditto
Core System
Ditto uses a customditto-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-subscriberwith 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.Related Documentation
- For debugging specific issues, see Troubleshooting
- For remote log collection, see Device Observability