Skip to content

Latest commit

 

History

History
111 lines (82 loc) · 3.22 KB

File metadata and controls

111 lines (82 loc) · 3.22 KB

logrustate

A modern, drop-in replacement for logrotate — written in Rust.

logrustate is designed to be fully compatible with the traditional logrotate configuration format, while bringing modern features like TOML configuration support, better performance, safety, and clear output formatting.

Why logrustate?

  • Fast & Safe — Built in Rust, offering memory safety and high performance.
  • Drop-in Compatible — Supports legacy logrotate.conf configuration syntax.
  • TOML Support — Allows writing structured configurations in modern TOML.
  • Robust Suffix Management — Supports both numeric and custom date-based suffix names (dateext).
  • Gzip Compression — Built-in fast gzip compression (flate2).
  • Dry-run Mode — Colorized preview output of what actions would be performed.

Installation

1. From Source (Cargo)

cargo install --git https://github.com/anilcan-kara/logrustate.git

2. Direct Binary Download

You can download the precompiled static binary for your platform directly from the GitHub Release assets:

CLI Usage

logrustate [FLAGS] [OPTIONS] <CONFIG_FILE>...

Flags & Options

  • -d, --debug — Dry-run mode. Implies --verbose and does not modify any files.
  • -v, --verbose — Print details during processing.
  • -f, --force — Force rotation of all logs, even if not yet scheduled.
  • -s, --state <PATH> — Path to the state file (defaults to /var/lib/logrustate/status).

Configuration Formats

1. Legacy Syntax (logrotate.conf compatible)

/var/log/nginx/*.log {
    daily
    rotate 7
    compress
    delaycompress
    missingok
    notifempty
    sharedscripts
    postrotate
        systemctl reload nginx
    endscript
}

2. Modern TOML Syntax

Create a configuration file with the .toml extension:

[global]
rotate = 4
compress = true

[[entries]]
paths = ["/var/log/app/*.log"]
frequency = "daily"
copytruncate = true

Systemd Integration

You can schedule logrustate using a Systemd timer.

Service File (/etc/systemd/system/logrustate.service)

[Unit]
Description=Rotate log files
Documentation=https://github.com/anilcan-kara/logrustate

[Service]
Type=oneshot
ExecStart=/usr/local/bin/logrustate /etc/logrustate.conf

Timer File (/etc/systemd/system/logrustate.timer)

[Unit]
Description=Daily rotation of log files

[Timer]
OnCalendar=daily
AccuracySec=1h
Persistent=true

[Install]
WantedBy=timers.target

License

This project is licensed under the MIT License.