graflog
Structured JSON logging optimized for Grafana ingestion. Clean enum-based configuration.
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
- Clean enum-based configuration
Installation
Usage
use ;
Configuration Options
Log Levels
LogOption::TraceLogOption::DebugLogOption::InfoLogOption::WarnLogOption::Error
Framework Filters
LogOption::RocketOff- Turn off rocket logsLogOption::ActixOff/LogOption::ActixWarn- Control actix_web logsLogOption::HyperOff/LogOption::HyperWarn- Control hyper logsLogOption::TokioOff/LogOption::TokioWarn- Control tokio logs
Console Control
LogOption::Console- Enable console output (default)LogOption::NoConsole- Disable console output
Custom Filters
LogOption::Custom("target=level".to_string())- Any custom filter
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"
Migration from Previous Versions
Old syntax:
init_logging!;
New syntax:
init_logging!;