Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/estk/log4rs
A highly configurable logging framework for Rust
https://github.com/estk/log4rs
json log logging rust xml
Last synced: about 2 months ago
JSON representation
A highly configurable logging framework for Rust
- Host: GitHub
- URL: https://github.com/estk/log4rs
- Owner: estk
- License: apache-2.0
- Created: 2015-01-27T17:09:19.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2024-04-18T05:24:32.000Z (8 months ago)
- Last Synced: 2024-05-02T00:05:32.152Z (7 months ago)
- Topics: json, log, logging, rust, xml
- Language: Rust
- Homepage:
- Size: 2.49 MB
- Stars: 945
- Watchers: 13
- Forks: 142
- Open Issues: 52
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-rust-cn - sfackler/log4rs - ci.org/sfackler/log4rs.svg?branch=master)](https://travis-ci.org/sfackler/log4rs) (Libraries / Logging)
- awesome-rust - estk/log4rs
- awesome-rust-cn - estk/log4rs
README
# log4rs
[![docs](https://docs.rs/log4rs/badge.svg)](https://docs.rs/log4rs)
[![crates.io](https://img.shields.io/crates/v/log4rs.svg)](https://crates.io/crates/log4rs)
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](#license)
![CI](https://github.com/estk/log4rs/workflows/CI/badge.svg)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.69+-green.svg)](https://github.com/estk/log4rs#rust-version-requirements)log4rs is a highly configurable logging framework modeled after Java's Logback
and log4j libraries.## Quick Start
log4rs.yaml:
```yaml
refresh_rate: 30 seconds
appenders:
stdout:
kind: console
requests:
kind: file
path: "log/requests.log"
encoder:
pattern: "{d} - {m}{n}"
root:
level: warn
appenders:
- stdout
loggers:
app::backend::db:
level: info
app::requests:
level: info
appenders:
- requests
additive: false
```lib.rs:
```rust
use log::{error, info, warn};
use log4rs;fn main() {
log4rs::init_file("config/log4rs.yaml", Default::default()).unwrap();info!("booting up");
// ...
}
```## Rust Version Requirements
1.69
## Building for Dev
* Run the tests: `cargo test --all-features`
* Run the tests for windows with [cross](https://github.com/rust-embedded/cross):
`cross test --target x86_64-pc-windows-gnu`
* Run the tests for all individual features: `./test.sh`
* Run the tests for all individual features for windows with
[cross](https://github.com/rust-embedded/cross): `./test.sh win`## Compression
If you are using the file rotation in your configuration there is a known
substantial performance issue with the `gzip` feature. When rolling files
it will zip log archives automatically. This is a problem when the log archives
are large as the zip happens in the main thread and will halt the process while
the zip is completed.The methods to mitigate this are as follows.
1. Use the `background_rotation` feature which spawns an os thread to do the compression.
2. Do not enable the `gzip` feature.
3. Ensure the archives are small enough that the compression time is acceptable.For more information see the PR that added [`background_rotation`](https://github.com/estk/log4rs/pull/117).
## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or )
* MIT license ([LICENSE-MIT](LICENSE-MIT) or )at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you shall be dual licensed as above, without any
additional terms or conditions.