Getting started with Logs - Docs - PostHog

Getting started with Logs

Use your logging client

PostHog Logs works with any OpenTelemetry client. No PostHog-specific packages required. Use the OTel SDKs you already have, point them at PostHog's HTTP endpoint, and drop in your project token.

On the frontend, our JavaScript web SDK, React Native SDK, iOS SDK, and Android SDK include first-class logging support.

Follow the guides below to set up your logging client:

Configure logging client

Send context-rich logs

PostHog ingests logs in the same pattern as OTel's structured logging model: resource attributes, log attributes, and trace context.

Enrich your logs with granular detail and business context for INFO, DEBUG, WARN, and ERROR log levels.

Python

import logging

# Configure logging to use OpenTelemetry
logging.basicConfig(level=logging.INFO)
logging.getLogger().addHandler(LoggingHandler())

# Use standard Python logging
logger = logging.getLogger("my-app")
logger.info("User action", extra={"userId": "123", "action": "login"})
logger.warning("Deprecated API used", extra={"endpoint": "/old-api"})
logger.error("Database connection failed", extra={"error": "Connection timeout"})

Learn best practices

Search and analyze your logs

Once your logs are flowing into PostHog, you can:

Learn how to search logs

Analyze log patterns

The Patterns view automatically mines your logs to find recurring message templates. Use it to spot noisy log lines consuming your log budget, find new error shapes by their template structure, and see which patterns dominate your log volume.

Expand any pattern and click View matching logs to pivot to the Logs view filtered to lines matching that template. The filter lands in the filter bar as a visible, removable chip, and your date range, service, and severity selections carry over.

Explore log patterns

Set up alerts

Get notified when your logs match specific conditions. Create alerts to:

Configure alerting rules in your project settings to stay on top of issues as they happen.

Configure log alerts

Use MCP and AI to debug

Connect the PostHog MCP server and your AI agent can query logs directly. Use Cursor, Claude Code, or any MCP-compatible tool.

Your coding agent pulls the relevant logs it needs to debug and build faster without switching workflows.

Try asking your agent for these:

In the web app, you can also open a single log record and have PostHog AI explain it – what it means, what probably caused it, and what to do next.

Explore logs with AI

Integrate your product data

With PostHog, your logs live alongside your Product Analytics, Session Replays, Error Tracking, and Dashboards, so you can go from a log line to a user's session to the flag variant they were on without switching tools.

Session Replay

Log events in PostHog can be connected to the session and user who triggered them. Jump from a log line to a session replay in one click.

Product Analytics

Turn log patterns into trends, funnels, and retention insights. Know which logged errors actually hurt user retention vs. which are just noise.

Error Tracking

Logs with $exception events become issues you can assign, resolve, and alert on. No separate error tracking tool needed.

Dashboards

Add a Recent logs widget to any dashboard to monitor log entries alongside your other metrics and insights. Filter by severity level and service, and click a row to jump to that log on the Logs page.

Use for free

PostHog's Logs is built to be cost-effective by default, with a generous free tier and transparent usage-based pricing. Since we don't charge per seat, more than 90% of companies use PostHog for free.

TL;DR 💸


That's it! You're ready to start integrating.

Install logs