Documentation
Everything the package does, and how to make it do it.
Start with the quick start, read the concepts once, then keep the guides and the reference open. Every page is written from the code; every snippet runs as shown.
Getting started
- InstallationInstall the package, pick an entry point, and know which runtimes it runs on.
- Quick startThe default logger, a template, a level, a source, a context — in five minutes.
- Next.jsinstrumentation.ts, middleware, route handlers, server actions and client components.
- Node and ExpressA logger with a rolling file, request logging middleware, and a clean exit.
Concepts
- Message templatesThe grammar: holes, operators, formats, alignment, escaping, and the event-type hash.
- LevelsSix levels, minimums, per-source overrides, runtime switches, per-sink restrictions.
- Structured dataHow values are captured: scalars, objects, class instances, errors, limits, policies.
- Enrichment and contextEnrichers, the precedence of properties, and the ambient LogContext.
- SinksEvery built-in sink and wrapper, batching, sub-loggers, flush and close.
- FilteringExcluding, including, matching helpers, sampling and rate limiting.
- FormattingOutput templates, the JSON and CLEF formatters, the pretty console.
- ErrorsError-first calls, cause chains, own properties, and how each formatter renders them.
Guides
- Request loggingOne completion event per request, with a diagnostic context, for Next.js and Express.
- Timed operationsBegin, complete, abandon — one event with Outcome and Elapsed.
- RedactionKeys, dotted paths and wildcards; policies for whole types; what is not covered.
- ProductionJSON on stdout, environment variables, flushing, containers, Vercel and serverless.
- SeqShip CLEF to Seq and query by event type.
- OpenTelemetryOTLP/HTTP without the SDK, or a bridge to the SDK you already run.
- TestingAssert on templates and properties with the memory sink.
- BrowserThe root entry in the browser: the console sink, shipping over HTTP, the synchronous context.
- Migrating from pinoThe API side by side, and a pino-shaped JSON output.
- Migrating from winstonFormats become formatters, transports become sinks.
- For Serilog usersEvery Serilog API and its logit spelling, and the two things that differ.