The otlp log channel
The package automatically registers an otlp log channel in Laravel’s logging system. You can reference it directly in config/logging.php without defining it yourself, but you can also override its configuration:
Logger facade, which emits it as an OpenTelemetry log record with the correct severity, timestamp, and any active trace context.
Set otlp as the default channel
To send all application logs to OpenTelemetry, set it as the default channel:
Stack otlp with other channels
To send logs to both OpenTelemetry and another destination (for example, the standard daily file channel):
Logger facade
You can also send logs directly to OpenTelemetry without going through Laravel’s log system by using theLogger facade:
$context array as a second argument:
log method with a PSR-3 log level:
Trace ID injection
Correlating logs with traces lets you jump from a log record directly to the trace in your observability backend. This package supports trace ID injection in two ways:Automatic injection via the otlp channel
When you use the otlp log channel or the Logger facade, the active trace ID is always included in the exported log record. No additional configuration is needed.
Injection into other log channels
When using other log channels (for example,daily or stderr), the package can inject the trace ID into Laravel’s shared log context so it appears in every log record:
updateLogContext is called automatically at the start of each request.
Configuration
Trace ID injection is controlled by two options inconfig/opentelemetry.php:
| Option | Default | Description |
|---|---|---|
logs.inject_trace_id | true | Inject the trace ID into the log context for non-OTLP log channels |
logs.trace_id_field | trace_id | Field name added to log records containing the trace ID |
When you start a root span manually (rather than relying on automatic instrumentation), call
Tracer::updateLogContext() after activating the span to ensure the trace ID is available in non-OTLP log channels.