graflog
Structured JSON logging optimized for Grafana ingestion. And abstraction boring tracing subscriber syntax, by the way.
Features
- JSON-only structured logging
- Grafana-optimized field naming
- Thread-safe file appending
- Zero-configuration setup
- Consistent timestamp formatting
- Service and component tagging
- Distributed tracing with spans
- Separate log level and filter configuration
Installation
Usage
use ;
Configuration Options
Log Levels
Supported levels: trace, debug, info, warn, error
Target Filters
Filter specific modules or crates:
"rocket::server=off"- Turn off rocket server logs"actix_web=warn"- Set actix_web to warn level"hyper=info,tokio=debug"- Multiple target filters
Console Output
Logs output to both file and console by default. Pass false as the console parameter to disable console output.
Grafana Integration
Logs are formatted with consistent fields:
service: Service identifiercomponent: Component within servicetimestamp: RFC3339 formatted timestamplevel: Log level (trace, debug, info, warn, error)- Custom fields from your log statements
Perfect for Grafana Loki queries:
{service="payment-service"} | json | level="error"
{service="auth-service"} | json | component="jwt"
Command Line Usage
Pass log file path and level at startup:
No environment files needed - all parameters passed directly.