Skip to content

Introduction ​

logixia is a TypeScript logging library for Node.js. It gives you structured logs with a small API, and it adds the things production services usually bolt on later: request trace IDs, secret redaction, sampling, graceful shutdown and a set of transports for files, databases, cloud log services and chat webhooks.

Every log method returns a Promise, so a slow transport never blocks your code unless you choose to await it. The package ships ESM and CommonJS builds with type declarations, has three runtime dependencies, and runs on Node.js 16 and later.

When to use it ​

logixia is a good fit when you:

  • run an HTTP service (Express, Fastify, NestJS) and want every log line tied to a request trace ID without passing the ID around by hand;
  • need to keep passwords, tokens and PII out of logs by configuration instead of by discipline;
  • ship logs to more than one place (console plus a file plus a cloud service) and want retries, batching and bounded buffers handled for you;
  • want typed custom levels, typed log fields and a mock logger for tests.

It is probably not the right tool if you need a logger that runs unchanged in every browser and edge runtime with the full feature set. The logixia/browser entry point covers those environments with a smaller logger; see Browser and edge.

A first look ​

ts
import { createLogger } from 'logixia';

const logger = createLogger({
  appName: 'api',
  environment: 'production',
  redact: { autoDetect: true },
});

await logger.info('Server started', { port: 3000 });
await logger.error(new Error('Payment gateway timed out'), { orderId: 'ord_123' });

Head to Getting started for installation and a runnable setup.

Feature map ​

AreaWhat you getRead
SetupInstall, first logger, transportsGetting started
OptionsEvery LoggerConfig option and its defaultConfiguration
LevelsBuilt-in and custom levels, runtime changes, per-namespace levelsLog levels
ContextChild loggers and fields that follow a requestChild loggers and context
TracingTrace IDs, traceparent, correlation IDs across servicesTracing
HTTPExpress middleware and Fastify plugin that replace MorganHTTP logging
NestJSModule, service, exception filter, decorators, interceptorsNestJS
SafetyPath and pattern redaction, auto-detection of secretsRedaction
VolumeRate, per-level, trace-consistent and adaptive samplingSampling
ObservabilityPrometheus metrics from logs, OpenTelemetry bridge, wide eventsMetrics, OpenTelemetry, Wide events
DeliveryConsole, file, database, cloud, analytics, Slack and Discord, worker threadTransports
LifecycleFlush on SIGTERM and SIGINTGraceful shutdown
TypesTyped log fields and schemasTyped logger
ExtensionPlugins and custom transportsPlugins, Custom transport
Browser and edgeSmall browser-safe logger with a remote batch transportBrowser and edge
AnalysisIn-memory log search and the logixia command line toolLog search, CLI
TestingMock logger with assertionsTesting
ReferenceSecurity notes, upgrade guide, FAQ, export listsSecurity, Migrating to 2.0, FAQ, API overview

Entry points ​

logixia exposes several import paths so you only load what you use. The main ones are logixia (logger, context, redaction, sampling, metrics), logixia/nest, logixia/middleware, logixia/correlation, logixia/transports, logixia/browser, logixia/search and logixia/testing. The API overview lists everything each one exports.

Released under the MIT License.