Skip to main content
Bifrost provides a flexible logging system with configurable log levels and output formats. You can use the built-in default logger or implement your own custom logger.

Using the Default Logger

Bifrost includes a DefaultLogger 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:
You can change the log level at runtime:

Output Formats

The default logger supports two output formats:

JSON Output (Default)

Structured JSON logs, ideal for log aggregation systems:
Output example:

Pretty Output

Human-readable colored output, ideal for development:
Output example:

Custom Logger Implementation

Implement the Logger 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