Other languages logs installation
PostHog logs works with any OpenTelemetry-compatible client. Check the OpenTelemetry documentation for your specific language or framework.
- 1
Install OpenTelemetry packages
RequiredThe key requirements are:
- Use OTLP (OpenTelemetry Protocol) for log export over HTTP
- Send logs to your PostHog logs endpoint (see configuration step below)
- Include your project token in the Authorization header or as a
?token=query parameter
Find the OpenTelemetry SDK for your language in the official registry.
- 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
RequiredConfigure your OpenTelemetry SDK to send logs to PostHog.
Endpoint:
Authentication: Include your project token either as an
Authorizationheader:Or as a query parameter on the endpoint:
- 4
Next steps
CheckpointWhat you can do with your logsAction Description 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 posthogDistinctIdandsessionIdLogging best practices Learn what to log, how to structure logs, and patterns that make logs useful in production