Rust logs installation
- 1
Install OpenTelemetry packages
RequiredTerminalImportant:
opentelemetry-otlpenables no TLS backend by default, soreqwest-rustlsis required to reach anhttpsendpoint. Without it, every export fails immediately withHTTP export failed: network error.This guide targets
opentelemetry*0.32 and needs 0.28 or later. If your application uses thelogcrate rather thantracing, swapopentelemetry-appender-tracingforopentelemetry-appender-log. - 2
Get your project token
RequiredYou'll need your PostHog project token to authenticate log requests. This is the same key you use for capturing events and exceptions with the PostHog SDK.
Important: Use your project token which starts with
phc_. Do not use a personal API key (which starts withphx_).You can find your project token in Project Settings.
- 3
Configure the SDK
RequiredSet up the OpenTelemetry SDK to send logs to PostHog.
RustAlternatively, you can pass the project token as a query parameter by modifying the URL path, though it will then appear in proxy and CDN access logs:
Rust - 4
Use OpenTelemetry logging
RequiredNow you can start logging with OpenTelemetry. The message becomes the log body, and structured fields become searchable attributes:
Rust - 5
Next steps
CheckpointWhat you can do with your logsAction Description Why you need logs What logs show you that nothing else does Search logs Use the search interface to find specific log entries Filter by level Filter by INFO,WARN,ERROR, etc.Link session replay Connect logs to users and session replays by passing posthogDistinctIdandsessionIdLink logs to a person Surface every log emitted on behalf of a user on their PostHog person profile Logging best practices Learn what to log, how to structure logs, and patterns that make logs useful in production