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:store.logger inside route handlers.
Configuration
Log Level
Pretty Printing
Redacting Sensitive Data
Base Fields
Pino Transports
Pino supports its own transport system for advanced logging destinations. You can configure Pino transports using thetransport option:
- Pino transports (
pino.transport) - Only affect logs written throughstore.pino.info(),store.pino.error(), etc. - Logixlysia transports (
config.transports) - Only affect Logixlysia’s internal HTTP request logging
- 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
-
Use Structured Logging - Pass objects instead of string interpolation
-
Create Child Loggers - For scoped logging with context
-
Log Performance Metrics - Track important metrics
-
Redact Sensitive Data - Always redact sensitive information
-
Use Appropriate Log Levels - Follow log level guidelines
fatal- Application is about to crasherror- Error that needs attentionwarn- Warning but application continuesinfo- General information (default)debug- Detailed debugging informationtrace- Very detailed debugging
-
Environment-based Configuration - Configure differently per environment
-
Export Pino for Standalone Use - Use in services, jobs, and utilities