Logged Docs
Logged Docs

Getting Started

  • Installation
  • Quick Start

SDK

  • Logger
  • Capture Errors
  • Browser Auto Capture
  • Console Capture

REST API

  • Overview

Examples

  • Next.js
  • React
  • JavaScript
Back to site
Back to SDK

Console Capture

Send existing browser console output to Logged without replacing your normal console behavior.

Setup

typescript
import { Logged } from "@logged/sdk";

const logger = new Logged({
  apiKey: process.env.NEXT_PUBLIC_LOGGED_API_KEY!,
});

logger.interceptConsole();

After calling interceptConsole(), the following browser methods are forwarded to Logged while still appearing in DevTools:

  • console.log
  • console.info
  • console.warn
  • console.error

How it works

typescript
console.log("Application started");

console.info("User authenticated");

console.warn("API response is slow");

console.error("Payment failed");

Each call still prints to the browser console. Logged receives a structured copy with the log level, message, and serialized arguments.

Serialization

Console arguments are serialized safely so objects, arrays, and circular references do not break the SDK.

typescript
console.log("User:", {
  id: "123",
  role: "admin",
});

This produces a Logged event with the object preserved in metadata rather than stringified into [object Object].

Cleanup

typescript
logger.stopConsoleInterception();

Restores the original console methods. This is useful in tests or when disabling capture for part of an application lifecycle.

Notes

Browser only

Console interception targets the browser. It does not modify Node.js server-side console behavior.

Multiple calls are safe

Calling interceptConsole() multiple times does not wrap the same methods more than once.