Skip to main content
Logixlysia can integrate with Pino, a high-performance JSON-first logging library, as an optional logging backend.

Why Pino?

  • High Performance - One of the fastest Node.js loggers available
  • Structured Logging - JSON-first approach for better log parsing
  • Production Ready - Battle-tested in production environments
  • Flexible - Extensive configuration options and transport support

Basic Usage

In Elysia Routes

Access Pino through the store in your route handlers:

Outside Elysia Routes (Standalone)

Use Pino in services, background jobs, or any code outside of HTTP request context:
Note: When using Pino outside of routes, you won’t have access to HTTP context (method, pathname, IP, etc.). For HTTP request logging, use store.logger inside route handlers.

Configuration

Log Level

Pretty Printing

Or with custom options:

Redacting Sensitive Data

Or with paths:

Base Fields

Pino Transports

Pino supports its own transport system for advanced logging destinations. You can configure Pino transports using the transport option:
Important: Pino transports are separate from Logixlysia’s transport system:
  • Pino transports (pino.transport) - Only affect logs written through store.pino.info(), store.pino.error(), etc.
  • Logixlysia transports (config.transports) - Only affect Logixlysia’s internal HTTP request logging
For example:
This separation allows you to:
  • Use Pino transports for structured application logs (store.pino.*)
  • Use Logixlysia transports for HTTP request/response logs
  • Configure different destinations for different log types

Advanced Usage

Structured Logging

Child Loggers

Create child loggers with context:

Performance Logging

Error Logging

Environment-based Configuration

Best Practices

  1. Use Structured Logging - Pass objects instead of string interpolation
  2. Create Child Loggers - For scoped logging with context
  3. Log Performance Metrics - Track important metrics
  4. Redact Sensitive Data - Always redact sensitive information
  5. Use Appropriate Log Levels - Follow log level guidelines
    • fatal - Application is about to crash
    • error - Error that needs attention
    • warn - Warning but application continues
    • info - General information (default)
    • debug - Detailed debugging information
    • trace - Very detailed debugging
  6. Environment-based Configuration - Configure differently per environment
  7. Export Pino for Standalone Use - Use in services, jobs, and utilities

Additional Resources