Deploying your App
SDK Logging
Learn how to configure and use the logging system in the Ditto SDK for monitoring and debugging your applications.
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
Parameter | Default | Range | Description |
---|---|---|---|
rotating_log_file_max_size_mb | 1MB | 1MB-1GB | Size trigger for rotation |
rotating_log_file_max_age_h | 24 | 1+ hours | Age trigger for rotation |
rotating_log_file_max_files_on_disk | 15 | 3-64 files | Maximum files to retain |
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.
Related Documentation
- For debugging specific issues, see Troubleshooting
- For remote log collection, see Device Observability