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 โ same log format, same file naming convention, same TTL-based cleanup.
Features
- ๐ Writes to
<app_name>.log, rotates to<app_name>.log.YYYYMMDDHHevery hour - ๐งน Auto-deletes files older than
ttl_hours(default 72 h) - โก All I/O on a dedicated background thread โ calling threads never block
- ๐ Zero
unsafecode - ๐ฏ Drop-in with the standard
logcrate โ no changes to existinglog::info!calls
Log Format
[2026-04-21 10:28:35.123] [INFO] my-app - Application started
[2026-04-21 10:28:35.124] [WARN] my-app - Low disk space
[2026-04-21 10:28:35.125] [ERROR] my-app - Connection failed: timeout
Installation
[]
= "0.1"
= "0.4"
Quick Start
use ;
use LevelFilter;
use PathBuf;
Configuration
| Field | Type | Default | Description |
|---|---|---|---|
app_name |
String |
"app" |
App / category name. Used in log lines and filenames |
log_dir |
PathBuf |
system temp | Directory where log files are created |
ttl_hours |
i64 |
72 |
Hours to retain rotated log files |
level |
LevelFilter |
Info |
Minimum log level written to file |
console |
bool |
true (debug) / false (release) |
Also print to stderr |
File Naming
| File | Description |
|---|---|
my-app.log |
Current log file (active) |
my-app.log.2026042110 |
Rotated archive for the 10:00โ11:00 slot on 2026-04-21 |
Comparison with @imcooder/node-logger
| Feature | @imcooder/node-logger |
logger-nx |
|---|---|---|
| Log format | [time] [LEVEL] app - msg |
[time] [LEVEL] app - msg โ
|
| File naming | app.log.YYYYMMDDHH |
app.log.YYYYMMDDHH โ
|
| Hourly rotation | โ | โ |
| TTL cleanup | โ (72 h default) | โ (72 h default) |
| Async I/O | โ (Node streams) | โ (background thread + channel) |
| Console output | โ | โ |
| Zero blocking | โ | โ |
License
MIT ยฉ imcooder