Using the Default Logger
Bifrost includes aDefaultLogger that writes to stdout/stderr with timestamps. Create one with your desired log level:
Log Levels
Bifrost supports four log levels, from most to least verbose:| Level | Constant | Description |
|---|---|---|
| Debug | schemas.LogLevelDebug | Detailed debugging information for development |
| Info | schemas.LogLevelInfo | General operational messages |
| Warn | schemas.LogLevelWarn | Potentially harmful situations |
| Error | schemas.LogLevelError | Serious problems requiring attention |
Output Formats
The default logger supports two output formats:JSON Output (Default)
Structured JSON logs, ideal for log aggregation systems:Pretty Output
Human-readable colored output, ideal for development:Custom Logger Implementation
Implement theLogger interface to integrate with your existing logging infrastructure:
Example: Zap Logger Integration
Example: Logrus Integration
Using Your Custom Logger
Pass your custom logger to Bifrost during initialization:Disabling Logging
To disable logging, implement a no-op logger:Best Practices
Development vs Production
Log Level Guidelines
- Debug: Use during development to trace request flow, inspect payloads, and diagnose issues
- Info: Use for normal operational events like successful requests, provider switches
- Warn: Use for recoverable issues like retries, fallback activations, deprecated usage
- Error: Use for failures that need attention but don’t crash the application
Next Steps
- Context Keys - Pass metadata through requests
- Provider Configuration - Configure multiple providers
- Streaming Responses - Real-time response handling
- Core Features - Advanced Bifrost capabilities

