Log Levels
The SDK supports four log levels defined in theLogLevel enum:
Log Level Hierarchy
Levels are ordered by severity:- DEBUG (20) - Logs all messages including request/response bodies
- INFO (40) - Logs request start, success, retries
- WARN (60) - Logs request failures and warnings (default)
- ERROR (80) - Logs only critical errors
Basic Configuration
Set the log level when creating the client:Default Logging (WARN)
By default, only warnings and errors are logged:Verbose Logging (DEBUG)
Enable debug logging to see all request details:Silent Logging (ERROR)
Only log critical errors:What Gets Logged
INFO Level Messages
Request Start:WARN Level Messages
Request Failure:DEBUG Level Messages
Failed Response Body:Custom Logger
Provide a custom logger function to send logs to your own logging system:Logger Type
TheLogger type is a function that receives three arguments:
The log level for this message (DEBUG, INFO, WARN, or ERROR).
A short description of the event (e.g.,
"request start", "request fail").Additional context as a key-value object (method, path, error codes, etc.).
Custom Logger Examples
Structured JSON Logging
Pino Logger
Winston Logger
Filter Sensitive Data
Only Log Errors
Production Best Practices
Development vs Production
Sampling High-Volume Logs
Log Aggregation
Debugging Tips
Enable Debug Logs Temporarily
Log Request IDs
Request IDs are automatically included in success and failure logs when available:Monitor Retry Patterns
SetlogLevel: LogLevel.INFO to see retry attempts:
Default Console Logger
The SDK uses a simple console logger by default:console.debug, console.info, console.warn, and console.error.