mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-02-17 14:07:28 +08:00
- Clarify that size-based rotation is already implemented - Update line numbers to match actual code location (line 407) - Mark patch as reference since changes are already applied - Remove misleading "recommended enhancement" language Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com>
2.4 KiB
2.4 KiB
Log File Management
Overview
RustDesk uses flexi_logger for logging with automatic log rotation. Logs are written to platform-specific directories and rotated to prevent excessive disk usage.
Current Implementation
Log Locations
- macOS:
~/Library/Logs/RustDesk/ - Linux:
~/.local/share/logs/RustDesk/ - Android:
{APP_HOME}/RustDesk/Logs/ - Windows: Config directory →
log/subdirectory
Current Rotation Policy
The logging system (implemented in libs/hbb_common/src/lib.rs) uses size-based rotation:
.rotate(
// Rotate logs daily OR when they reach 100MB (whichever comes first)
Criterion::AgeOrSize(Age::Day, 100_000_000),
Naming::Timestamps,
Cleanup::KeepLogFiles(31),
)
Benefits
- Bounded Disk Usage: Maximum log storage becomes ~3.1GB (31 files × 100MB)
- Maintained Organization: Daily rotation still occurs for time-based organization
- Prevents Runaway Logs: Heavy activity days can't create multi-gigabyte single files
- Automatic Cleanup: Old files still automatically deleted after 31 days
Implementation
The implementation is in the hbb_common library:
File: libs/hbb_common/src/lib.rs
Function: init_log()
Line: ~407
- Criterion::Age(Age::Day),
+ // Rotate logs daily OR when they reach 100MB to prevent excessive disk usage
+ // With 31 files max, this limits total log storage to ~3.1GB
+ Criterion::AgeOrSize(Age::Day, 100_000_000),
Tuning Parameters
The 100MB size limit can be adjusted based on deployment needs:
- 50MB (
50_000_000): More conservative, max ~1.5GB total - 100MB (
100_000_000): Balanced approach, max ~3.1GB total ✅ Recommended - 200MB (
200_000_000): Permissive, max ~6.2GB total
Monitoring
Users can monitor log disk usage at the locations listed above. The rotation ensures:
- Logs older than 31 days are automatically deleted
- Individual files never exceed the configured size limit
- Total disk usage is bounded and predictable
Testing
To verify the rotation works correctly:
- Check log directory before and after rotation
- Verify old files are cleaned up after 31 days
- Monitor file sizes don't exceed the configured limit
- Ensure logs still contain all necessary debugging information
References
- flexi_logger documentation: https://docs.rs/flexi_logger/
- RustDesk logging implementation:
libs/hbb_common/src/lib.rs