notlogs rocket
notlogs

Getting Started

Quick Start Guide

Send your first structured production event to NotLogs in 3 simple steps.

1

Install the SDK

Install the NotLogs Next.js SDK package using your package manager of choice:

bash
npm install @notlogs/next
2

Initialize the Logger

Create a logger instance by providing your API key from the API Keys dashboard:

lib/logger.ts
typescript
import { createLogger } from "@notlogs/next";

export const logger = createLogger({
  apikey: process.env.NOTLOGS_API_KEY || "SEL_YOUR_API_KEY",
  appName: "ecommerce-web",
  enviorment: process.env.NODE_ENV || "production",
});
3

Send Structured Events

Log application events with convenience helper methods:

app/api/checkout/route.ts
typescript
import { logger } from "@/lib/logger";
import { NextResponse } from "next/server";

export async function POST(req: Request) {
  try {
    const { userId, amount } = await req.json();

    // Log an informational business event
    logger.info({
      message: `User completed checkout of $${amount}`,
      service: "payment-service",
      operation: "checkout",
      track: { userId },
      metrics: { durationMs: 145 },
    });

    return NextResponse.json({ success: true });
  } catch (error: any) {
    // Log critical errors that can trigger instant webhook alerts
    logger.error({
      message: `Checkout failed: ${error.message}`,
      importance: "critical",
      service: "payment-service",
      subsystem: "db",
    });

    return NextResponse.json({ error: "Checkout error" }, { status: 500 });
  }
}
4

Watch in Real-Time

Head to your Live Logs Dashboard to stream events live with zero latency.