Pino Integration
High-performance structured logging with Pino in Logixlysia.
Logixlysia integrates Pino, a high-performance JSON-first logging library, as its primary logging backend. This integration provides structured logging capabilities while maintaining backward compatibility with the existing Logixlysia API.
Why Pino?
Pino offers several advantages for production logging:
- High Performance - One of the fastest Node.js loggers available
- Structured Logging - JSON-first approach for better log parsing and analysis
- Production Ready - Battle-tested in production environments
- Flexible - Extensive configuration options and transport support
- Standards Compliant - Follows logging best practices
Basic Usage
Pino is integrated automatically when you use Logixlysia. No additional setup is required:
Configuration
Configure Pino through the config.pino option:
Log Level
Set the minimum log level:
Pretty Printing
Enable pretty printing for development:
Or with custom options:
Custom Keys
Customize the message and error field names:
Redacting Sensitive Data
Redact sensitive fields from logs:
Or with paths:
Base Fields
Add base fields to all logs:
Timestamp Configuration
Configure timestamp format:
Or use a custom timestamp function:
Transport Configuration
Configure custom transports for advanced logging:
Multiple transports:
Direct Pino Access
Access the Pino logger instance directly for advanced logging features:
Basic Access
Structured Logging
Log with structured data for better analysis:
Child Loggers
Create child loggers with context:
Performance Logging
Track operation performance:
Error Logging
Log errors with full context:
Environment-based Configuration
Configure Pino differently for development and production:
Development Configuration
Production Configuration
Migration Guide
If you're upgrading from a previous version of Logixlysia:
Backward Compatibility
All existing Logixlysia logging methods continue to work:
Accessing Pino
Now you can also access Pino directly:
No Breaking Changes
The integration is fully backward compatible. You can:
- Continue using existing Logixlysia methods
- Gradually adopt Pino features
- Mix both approaches in the same application
Best Practices
1. Use Structured Logging
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:
- trace - Very detailed debug information
- debug - Debug information for development
- info - General informational messages
- warn - Warning messages for potential issues
- error - Error messages for failures
- fatal - Critical errors that may cause shutdown
6. Environment-based Configuration
Configure differently per environment:
Complete Example
Here's a complete example combining multiple features: