Use the DIAL SDK formatter to define your own log shapes. This mode is controlled by DIAL_SDK_LOG_FORMAT.
Configuration Variables
| Variable | Default | Purpose |
|---|
DIAL_SDK_LOG | WARNING | Log level for the aidial_sdk logger |
DIAL_SDK_LOG_FORMAT | text | text (colored) or json (one line per record) |
DIAL_SDK_TEXT_LOG_FORMAT | (see below) | %-style format string for text mode |
DIAL_SDK_JSON_LOG_FORMAT | (see below) | JSON template for JSON mode |
Text Mode
Default text rendering uses uvicorn's DefaultFormatter. Use %(levelprefix)s for colored, aligned levels.
JSON Mode
Provide a JSON document where every string leaf is a %-style format string. The SDK interpolates these and then performs json.dumps().
Adding Trace/Span IDs in JSON Mode
If tracing is enabled, JSON mode automatically adds otelTraceID, otelSpanID, otelTraceSampled, and otelServiceName fields. To rename them, reference them in your template (this suppresses the auto-added copy).
# Custom Text Format
DIAL_SDK_TEXT_LOG_FORMAT='%(levelprefix)s %(name)s: %(message)s'
# Custom JSON Format with renamed trace_id
DIAL_SDK_JSON_LOG_FORMAT='{"level":"%(levelname)s","message":"%(message)s","trace_id":"%(otelTraceID)s"}'