Expand description
§logger-nx
A high-performance hourly-rotating file logger for Rust, implementing the
log facade. Behaviorally equivalent to the Node.js
@imcooder/node-logger library.
§Features
- Active log written to
<app_name>.log - Every hour the active file is renamed to
<app_name>.log.YYYYMMDDHH - Files older than
ttl_hours(default 72 h) are deleted automatically - All I/O runs on a dedicated background thread (lock-free channel) — calling threads are never blocked
- Zero unsafe code
§Log format
[2026-04-21 10:28:35.123] [INFO] my-app - Application started§Quick start
use logger_nx::{Config, init};
use log::LevelFilter;
use std::path::PathBuf;
init(Config {
app_name: "my-app".to_string(),
log_dir: PathBuf::from("/var/log/my-app"),
ttl_hours: 72,
level: LevelFilter::Info,
console: true,
}).expect("logger init failed");
log::info!("Application started");
log::warn!("Low disk space");
log::error!("Connection failed: {}", "timeout");
// Before process exit:
logger_nx::shutdown();Structs§
- Config
- Configuration for
Logger. - Logger
- A
log::Logimplementation that writes to hourly-rotating files.