Built-in Logger
The framework includes a console logger with sensible defaults:Log Levels
The built-in logger supports four levels:| Level | When to Use | Default (Dev) | Default (Prod) |
|---|---|---|---|
debug | Detailed debugging info | ✅ | ❌ |
info | General information | ✅ | ❌ |
warn | Warnings, non-critical issues | ✅ | ✅ |
error | Errors, critical issues | ✅ | ✅ |
silent | Disable all logging | ❌ | ❌ |
debugin development (NODE_ENV !== "production")warnin production (NODE_ENV === "production")
Configuration Options
Level
Color
Colors are auto-detected but can be forced:Depth
Control how deeply objects are inspected:Using the Logger
The logger is available in handlers, middlewares, and result handlers:Log Output Format
The built-in logger outputs in this format:- debug - gray
- info - blue
- warn - yellow
- error - red
Custom Logger
You can use any logger withinfo(), debug(), error(), and warn() methods:
Winston
Pino
Child Logger
Create request-specific loggers with additional context:Access Logging
Log all incoming requests:Profiling
Measure execution time of operations:Advanced Profiling
Implementation Details
Here’s the built-in logger implementation:Best Practices
Use Appropriate Levels
debug: Detailed flow informationinfo: Important events (user actions)warn: Unexpected but handled situationserror: Failures requiring attention
Include Context
Always include relevant data with logs for easier debugging.
Don't Log Secrets
Never log passwords, tokens, API keys, or sensitive user data.
Use Structured Logging
Log objects, not concatenated strings:
logger.info("User login", { userId }) not logger.info(\User $ login`)`Common Patterns
Request/Response Logging
Error Logging
Performance Logging
Troubleshooting
No Logs Appearing
Check:- Log level isn’t set to
silent - Level allows the messages (
warnwon’t showdebug) - Custom logger implements all required methods
Colors Not Working
Ensure:- Terminal supports colors
color: trueis set (or auto-detect works)- Output is to a TTY (colors disabled when piping)