Skip to content

[enhancement] Log file grows without bound — replace startup rename with proper rolling rotation #5478

@robster7674

Description

@robster7674

Recently I was wondering what was causing the beachballs when trying to export logs on macOS. Here's the analysis.

TLDR: there is no log rotation and the nym-vpnd.log in /private/var/log/nym-vpnd/ grows unbounded.


Title: Log file grows without bound — replace startup rename with proper rolling rotation

Repo: nym-vpn-client
Component: nym-vpn-core/crates/nym-vpn-lib/src/logging.rs
Type: Enhancement / Bug

Description:

nym-vpnd.log has no rolling rotation policy. The current implementation in logging.rs performs a single rename on daemon startup (nym-vpnd.lognym-vpnd.old.log), giving at most two files that grow without bound between restarts. After approximately one week of continuous uptime, the log file reaches 287MB and 1.4 million lines. This directly causes a 30–60 second beach ball when the user opens the log viewer in the macOS app.

Current behaviour (FileAppender::new):

// On startup: rename current → .old, then append forever
std::fs::rename(&log_file_path, &old_log_file_path);
tracing_appender::rolling::never(log_dir.clone(), log_file_name)

Expected behaviour:
Size- or time-based rolling rotation, keeping a small number of compressed archives, so that total on-disk log footprint is bounded regardless of uptime.

Suggested fix:
tracing_appender::RollingFileAppender is already imported but unused for rolling. Replace rolling::never() with a size- or daily-based appender, for example:

tracing_appender::rolling::daily(log_dir, log_file_name)
// or size-based with a third-party rolling appender crate

Retain the last 3–5 rotated files and gzip-compress them. A reasonable target is a maximum of ~50MB total log footprint.

Contributing factor:
Log verbosity is a significant multiplier. nym_dns::imp emits 4 near-identical "Saving DNS settings []" lines approximately every 600ms for empty NetBird DNS entries, which alone accounts for a large share of the file size and should be addressed separately.

Environment:

  • macOS 14.8.5 Sonoma (x86_64)
  • nym-vpn-lib 1.29.1
  • Log observed: 287MB, ~1.4M lines, ~7 days uptime, single continuous session

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions