Default behavior
Without observability config, the SDK uses a default logger writing to stderr at levelerror. Set the level with WithLogLevel:
OTLP log export
WhenWithObservabilityConfig is set and DisableLogs is false, SDK logs export to your OTLP backend automatically — the default logger is bridged to the same OpenTelemetry LoggerProvider:
WithLogger call is needed for OTLP — the SDK wires logger.DefaultLoggerWithOtelProvider when logs are enabled.
Use the same WithObservabilityConfig and log level on NewAgentWorker for worker-side log export.
Custom logger + OTLP
If you passWithLogger with a custom logger, OTLP logs from WithObservabilityConfig are not automatically bridged — the SDK warns at build time. Bridge manually:
WithObservabilityConfig enables logs, any standalone WithLogs value is replaced by the OTLP client built from config.
Bring your own logs exporter
UseWithLogs with observability.NewLogs when not using WithObservabilityConfig:
Disable logging
Log levels
Shutdown and flush
OTLP log records are batched before export. Allow a brief drain window on shutdown in production — call
Agent.Close() or AgentWorker.Stop() before the process exits, not just on signal receipt.Integrate with your logging pipeline
Write to a file or stdout — override the default logger with a custom writer:slog pipeline — implement interfaces.Logger wrapping your handler and pass it to WithLogger.
Hooks logging
Hook examples in the repository log hook activity to stderr with a[hooks] prefix. See Hooks and Hooks example.
Example: Observability · Logs example.
Example
Observability
OTLP traces, metrics, and logs
Related
Tracing
OTLP traces in the same config block
Metrics
OTLP metrics export