log4you
Structured logging for Rust with dynamic UUID log IDs, built on log4rs.
log4you is a lightweight logging crate, designed for applications that need consistent, structured logging with unique log identifiers (UUIDs). It allows simple, efficient, and consistent logging with unique log IDs for each request.
โจ Features
- ๐ง Powered by
log4rs, configure logging dynamically with YAML configuration files, compatible with the standard Rustlogfacade - โ Structured logging with automatic UUID log IDs
- ๐ Generates a unique
log_id(UUID v7) per log entry - ๐ช Easy-to-use macros:
log_info!,log_error!, etc. - ๐ ๏ธ Supports dynamic config paths, log rotation, and file size management
- ๐ Easy setup and integration โ works out of the box
- ๐งต Great for async or multi-threaded apps
Perfect for microservices, APIs, and any system where traceability and clean logs matter.
๐ฆ Installation
Add log4you to your Cargo.toml:
[]
= "0.1.1"
Or, use cargo-edit to add it directly from your terminal:
โ๏ธ Example YAML Configuration
See the log4rs configuration documentation for more details.
appenders:
stdout:
kind: console
encoder:
pattern: "[{d(%Y-%m-%dT%H:%M:%S%.6f)} {h({l})} {f}:{L}] - {m}{n}"
log4you:
kind: rolling_file
path: "logs/log4you.log"
policy:
kind: compound
trigger:
kind: size
limit: 100MB
roller:
kind: fixed_window
pattern: "logs/log4you-{}.log"
count: 5
encoder:
pattern: "[{d(%Y-%m-%dT%H:%M:%S%.6f)} {h({l})} {f}:{L}] - {m}{n}"
root:
level: info
appenders:
- stdout
loggers:
log4you:
level: debug
appenders:
- log4you
๐ ๏ธ Usage Example
use ;
Author
Jerry Maheswara jerrymaheswara@gmail.com
๐ License
This project is licensed under the Apache-2.0 license.
Built with โค๏ธ in Rust
Changelog
[v0.1.2]
- Re-export
logas__log_crateto support internal macro resolution without requiring users to depend onlogexplicitly. - Re-export
uuidas__uuid_cratefor similar internal macro usage convenience.