Generated banner for Logs Nodejs
Generated logo for Logs Nodejs

Logs Nodejs

PostHogOfficialCreated by PostHog

  • Skill
  • Tool integration
  • Data and AI
  • MIT
  • No issues found

From the author

PostHog logs for Node.js
— the description by PostHog

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides guidance and best practices for configuring Node.js applications to export logs to PostHog. It emphasizes the use of the OpenTelemetry protocol (OTLP) to send structured logs, ensuring that system telemetry is centralized and actionable. The skill focuses on maintaining clean, high-signal logging by advocating for wide events over granular, repetitive log lines, and provides instructions on how to leverage PostHog's ecosystem for debugging and analysis.

What it does

  • Guides the setup of OpenTelemetry log exporters for Node.js.
  • Promotes structured logging patterns for better queryability.
  • Provides best practices for creating wide, context-rich log events.
  • Explains how to integrate logs with other PostHog features like session replay.
  • Offers troubleshooting and search strategies for production logs.
  • Supports AI-assisted debugging via the PostHog MCP server.

When to use it

  • When you need to centralize logs from Node.js services into PostHog.
  • When transitioning from verbose, low-value logs to structured, wide events.
  • When you want to correlate system logs with user sessions and product analytics.
  • When setting up observability for new or existing Node.js backend services.

Advantages

  • Centralizes logs alongside product analytics and session replays.
  • Reduces noise by encouraging high-signal, structured log events.
  • Uses industry-standard OpenTelemetry protocols.
  • Enables deep correlation between system behavior and user activity.

Usage examples

“How do I configure my Node.js app to send logs to PostHog using OpenTelemetry?”
The agent provides the necessary configuration steps for the OTLP exporter and explains how to point it to the PostHog ingest endpoint.
“Help me refactor my repetitive logger.info calls into a single wide event.”
The agent analyzes your current logging code and suggests a structured JSON object that captures the request context, duration, and relevant metadata in one line.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/posthog/logs-nodejs/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip logs-nodejs.zip -d .agents/skills

Documentation by PostHog

PostHog logs for Node.js

This skill helps you add PostHog log ingestion to Node.js applications.

Reference files

  • references/nodejs.md - Node.js logs installation - docs

  • references/start-here.md - Getting started with logs - docs

  • references/search.md - Search logs - docs

  • references/best-practices.md - Logging best practices - docs

  • references/troubleshooting.md - Logs troubleshooting - docs

  • references/link-session-replay.md - Link session replay - docs

  • references/debug-logs-mcp.md - Debug logs with mcp - docs

Consult the documentation for API details and framework-specific patterns.

Key principles

  • Environment variables: Always use environment variables for PostHog keys and OpenTelemetry endpoints. Never hardcode them.

  • Minimal changes: Add log export alongside existing logging. Don't replace or restructure existing logging code.

  • OpenTelemetry: PostHog logs use the OpenTelemetry protocol. Configure an OTLP exporter pointed at PostHog's ingest endpoint.

  • Structured logging: Prefer structured log formats with key-value properties over plain text messages.

Framework guidelines

No specific framework guidelines.

Files

references/troubleshooting.md

Logs troubleshooting - Docs

This page covers troubleshooting for Logs. For setup, see the installation guide.

Have a question? Ask PostHog AI

Ask PostHog AI

Authentication errors

Problem: Getting 401 Unauthorized errors when sending logs.

Solutions:

  • Verify you're using the correct project token from Project Settings

  • Check the Authorization header format: Bearer <ph_project_token>

  • If using query parameter, verify the format: ?token=<ph_project_token>

  • Ensure your project token hasn't been rotated or revoked

Connection issues

Problem: Cannot connect to the PostHog logs endpoint.

Solutions:

  • Verify the endpoint URL: https://us.i.posthog.com/i/v1/logs

  • Check that your application can make outbound HTTPS requests

  • Ensure firewall rules allow outbound connections to PostHog

  • For self-hosted instances, verify the endpoint is correct for your deployment

Logs not appearing in PostHog

Problem: Logs are being sent but don't appear in the PostHog interface.

Solutions:

  • Verify your project token is correct and associated with the right project

  • Check that logs are being sent in the correct OTLP format

  • Ensure your project has access to the Logs feature in PostHog

  • Check the network tab in your browser/application to verify requests are succeeding (200 status)

Performance issues

Problem: High memory usage or slow log processing.

Solutions:

  • Adjust the batch size in your OpenTelemetry configuration

  • Use BatchLogRecordProcessor instead of SimpleLogRecordProcessor for better performance

  • Consider filtering logs on the client side to reduce volume

  • Check for network latency between your application and PostHog

Log format problems

Problem: Logs are being received but not parsed correctly.

Solutions:

  • Ensure you're using the standard OTLP log format

  • Verify log levels are set correctly (INFO, WARN, ERROR, etc.)

  • Check that log attributes are properly structured

  • Use the OpenTelemetry logging APIs instead of raw log libraries

Project token authentication issues

Problem: Confused about which key to use or how to authenticate.

Solutions:

  • Use your project token (the same one you use for capturing events)

  • Find it in Project Settings

  • You can authenticate in two ways:

    • Header: Authorization: Bearer <ph_project_token>

    • Query param: ?token=<ph_project_token>

  • Do not use your personal API key or other authentication methods

Self-hosted endpoint issues

Problem: Logs not working with self-hosted PostHog.

Solutions:

  • Use your self-hosted instance URL instead of https://us.i.posthog.com

  • Verify the logs endpoint is enabled on your self-hosted instance

  • Check that the endpoint path is correct: /logs

  • Ensure your PostHog version supports the logs feature

Still having issues?

If you're still experiencing problems:

  1. Verify your OpenTelemetry client configuration matches the examples in the installation guide

  2. Test with a simple log message first before sending complex logs

  3. Check the network requests to see the actual HTTP status codes and error messages

  4. Contact PostHog support with your specific error messages and configuration details

Community questions

Ask a question

Was this page useful?

HelpfulCould be better

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
PostHog
Publisher
PostHog (Official)
Source
PostHog/skills · skills/posthog/logs/skills/nodejs · commit a5d30e7
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Also distributed in
PostHog/skills

AutoGineer is not affiliated with or endorsed by PostHog or PostHog.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download logs-nodejs.zip