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 includes 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:

  • Search through logs using full-text searches, multiple search tokens, and negative filters
  • Filter by time ranges to find specific events
  • Filter on attributes for specific resources or events
  • Correlate logs with events from your PostHog analytics
PostHog Logs search interface
Learn how to search logs

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.

You can also ask PostHog AI to search and analyze your logs.

PostHog AI logs

Try out these prompts:

Explore logs with AI

Integrate your product data

With PostHog, your logs live alongside your Product Analytics, Session Replays, and Error Tracking, 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.

logs and errors

Product Analytics

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

logs and product analytics

Error Tracking

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

logs and session replay

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 💸

  • No credit card required to start
  • First 50 GB of ingested logs per month are free
  • Above 50 GB we have usage-based pricing at $0.25/GB with discounts
  • Set billing limits to avoid surprise charges
  • See our pricing page for more up-to-date details

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

Install logs

Community questions

Was this page useful?

Questions about this page? or post a community question.