| Crates.io | logforth |
| lib.rs | logforth |
| version | 0.27.0 |
| created_at | 2024-08-01 03:44:24.993417+00 |
| updated_at | 2025-08-18 01:06:19.538461+00 |
| description | A versatile and extensible logging implementation. |
| homepage | https://github.com/fast/logforth |
| repository | https://github.com/fast/logforth |
| max_upload_size | |
| id | 1321572 |
| size | 295,409 |
Logforth is a flexible and easy-to-use logging framework for Rust applications. It allows you to configure multiple dispatches, filters, and appenders to customize your logging setup according to your needs.
Add log and logforth to your Cargo.toml:
cargo add log
cargo add logforth
Set up a basic logger that outputs to stdout:
fn main() {
logforth::stdout().apply();
log::info!("This is an info message.");
log::debug!("This debug message will not be printed by default.");
}
Configure multiple dispatches with different filters and appenders:
use logforth::append;
use log::LevelFilter;
fn main() {
logforth::builder()
.dispatch(|d| d
.filter(LevelFilter::Error)
.append(append::Stderr::default()))
.dispatch(|d| d
.filter(LevelFilter::Info)
.append(append::Stdout::default()))
.apply();
log::error!("This error will be logged to stderr.");
log::info!("This info will be logged to stdout.");
log::debug!("This debug message will not be logged.");
}
Read more demos under the examples directory.
Read the online documents at https://docs.rs/logforth.
This crate is built against the latest stable release, and its minimum supported rustc version is 1.85.0.
The policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if Logforth 1.0 requires Rust 1.60.0, then Logforth 1.0.z for all values of z will also require Rust 1.60.0 or newer. However, Logforth 1.y for y > 0 may require a newer minimum version of Rust.
This crates has been in development since 2024-08. It is being used in several production systems stable enough to be considered mature, but it is still evolving. Read the following sections for what is stabilized and what is planned for the future.
Fundamental logging APIs are stabilized, including:
Append, Layout, Filter, Diagnostic and its VisitorDispatchBuilder, LoggerBuilder, and LoggerCore appenders, filters, layouts, and diagnostics are also stabilized, including:
Stdout, Stderr, and TestingEnvFilterTestLayout and JsonLayoutStaticDiagnostic and ThreadLocalDiagnosticOther appenders, filters, layouts, and diagnostics are still evolving and may change in future versions.
The following components yet to be unstabilized have known production usage and are considered reliable:
Fastrace, OpentelemetryLog, SingleFile, and RollingFileLogfmtLayout and GoogleCloudLoggingLayoutFastraceDiagnosticWhat about a 1.0 release?
The fundamental APIs and core components are stable. It's possible to factor out a separate logforth-api (or logforth-core) crate that contains only the stable APIs, and then release logforth-api 1.0 with the stable APIs and core components. I just don't decide its name and project layout yet.
The rest components, due to their external dependencies and several missing features, are still evolving and may change in future versions. They will be released as logforth-append-foo, logforth-filter-bar, logforth-layout-baz, and logforth-diagnostic-qux crates, which will depend on the stable logforth-api crate.
What are the missing features?
Before stabilize SingleFile, RollingFile and Syslog appenders that depend on the NonBlocking utility, I need to decide whether an AsyncAppend composition is better (see #145).
Otherwise, how to share utilities like NonBlocking and LevelColor between different separate crates without duplicating code is still an open question.
What about components that have external dependencies?
Fastrace's appenders and diagnostic, OpenTelemetry's appender, etc. have external dependencies that are not stable yet. The best option should be to release them as separate crates, such as logforth-append-fastrace, logforth-diagnostic-fastrace, logforth-append-opentelemetry, etc. This way, they can evolve independently and be used in projects that require them without affecting the core logging functionality.
This is blocked by not having a stable logforth-api crate yet, as these components depend on the stable APIs.
What is the future of the logforth crate?
It will continue to be the main crate that assembles all the features and provides a one-for-all dependency.
This project is licensed under Apache License, Version 2.0.
The name Logforth comes from an antonym to the Logback project, and may also be read as a homophone of "log force".