A lightweight, configurable request logging middleware for Axum.
Minimal request logging for Axum applications.
Features
- 🚀 Lightweight with minimal overhead
- ⚙️ Configure logger output through
logger_config.toml - 🎨 Colored HTTP status codes
- 📝 Human-readable log format
- 🔧 Easy integration using
middleware::from_fn - 📦 Works as a standalone library crate
- 💡 Sensible defaults with graceful fallback
Example Output
[MyBackend] | GET | /users/42 | 200 | 0.43ms | 2026-07-04 22:46:35
[MyBackend] | POST | /login | 401 | 1.81ms | 2026-07-04 22:46:38
[MyBackend] | DELETE | /users/5 | 500 | 3.22ms | 2026-07-04 22:46:41
Status codes are colorized automatically:
- 🟢 2xx — Green
- 🔵 3xx — Cyan
- 🟡 4xx — Yellow
- 🔴 5xx — Red
Installation
From crates.io
[]
= "0.1"
Local Path Dependency
[]
= { = "../axlogger" }
Usage
use ;
async
Create a logger_config.toml file in your project root.
Configuration
Example configuration:
[]
= "MyBackend"
= true
= true
= true
= true
= true
= true
= false
= true
| Option | Description |
|---|---|
project_name |
Project name shown in logs |
show_project_name |
Show or hide project name |
show_method |
Show or hide HTTP method |
show_path |
Show or hide request path |
show_status |
Show or hide status code |
show_duration |
Show or hide request duration |
show_timestamp |
Show or hide timestamp |
show_query_string |
Include query parameters in the request path |
colored |
Enable or disable colored output |
Running the Demo
Run the included example server:
Then send a few requests:
Project Structure
axlogger/
├── Cargo.toml
├── logger_config.toml
├── README.md
├── src/
│ └── lib.rs
└── examples/
└── demo.rs
- src/lib.rs — Middleware implementation and configuration loader.
- examples/demo.rs — Example Axum application demonstrating integration.
Design Goals
AxLogger is intentionally designed to be:
- Small
- Easy to integrate
- Dependency-light
- Beginner-friendly
- Configurable without recompilation
- Suitable for local development and small to medium-sized services
It is not intended to replace full-featured observability solutions such as tracing, but instead provides a simple request logger for projects where minimal setup is preferred.
Notes
- Configuration is loaded once during application startup.
- Restart the server after modifying
logger_config.toml. - Invalid or missing configuration files automatically fall back to default values.
- The logger never causes your application to fail because of configuration errors.
Contributing
Contributions, suggestions, and bug reports are always welcome.
Feel free to open an issue or submit a pull request.
License
Licensed under either of the following licenses, at your option:
- MIT License
- Apache License 2.0