Logger
Logging is a foundational requirement for debugging, monitoring, and operating production-grade backend systems.
The Servercn Logger component provides two interchangeable logging strategies so you can choose what best fits your application:
- Winston — flexible, feature-rich, file-based logging
- Pino — ultra-fast, JSON-first logging optimized for performance
Installation Guide
Install the component using the servercn CLI:
npx servercn-cli add loggerYou will be prompted to select a file upload provider:
The CLI will then automatically configure the component based on your selected library.
Prerequisites
Basic Implementation
1. Winston Logger
Minimal Configuration
Advanced Configuration
Winston Usage Example
Winston Usage Output
Child Logger
2. Pino Logger
Minimal Configuration
Advanced Configuration
Pino Usage Example
Pino Usage Output
NODE_ENV: production
NODE_ENV: development
Child Logger