The MCP Gateway uses a configurable logging system optimized for production environments.
In production (NODE_ENV=production), only ERROR and CRITICAL logs are shown by default.
Logging can be configured through environment variables:
Controls the verbosity of logs. Available levels:
ERROR(0) - Only errors (default in production)CRITICAL(1) - Critical information and errorsWARN(2) - Warnings, critical info, and errorsINFO(3) - General info, warnings, critical, and errors (default in development)DEBUG(4) - All logs including debug information
When set to production:
- Default log level is
ERROR - Colors are disabled by default
- Only critical information is logged
Example:
# Production mode - minimal logging
NODE_ENV=production npm start
# Development mode with debug logs
LOG_LEVEL=DEBUG npm start
# Production with critical info
NODE_ENV=production LOG_LEVEL=CRITICAL npm startControls whether timestamps are included in logs.
- Default:
true - Set to
falseto disable timestamps
Example:
LOG_TIMESTAMP=false npm startControls whether logs are colorized.
- Default:
true - Set to
falseto disable colors (useful for log files)
Example:
LOG_COLORS=false npm start > logs.txtLogs follow this format:
[timestamp] [prefix] [level] message
Example:
[2024-01-20T10:30:45.123Z] [MCP-Gateway] [INFO] Creating new session for server: linear
[2024-01-20T10:30:45.456Z] [Session:abc12345] [INFO] Connected to upstream with sse transport
- Connection failures
- Critical errors that prevent operation
- Unhandled exceptions
- Session initialization failures
- Server startup/shutdown events
- Session recovery status
- Important lifecycle events that should always be logged
- Session not found
- Rate limiting triggered
- Invalid requests
- Non-critical failures
- Session creation/restoration
- Transport connections established
- Tool filtering applied
- General operational events
- Request/response details
- Transport state changes
- Detailed operation flow
- Capability discovery
The logger is automatically created with appropriate prefixes:
MCP-Gateway- Main gateway operationsSession:{id}- Session-specific operations (truncated ID for readability)
For production environments (automatic minimal logging):
NODE_ENV=production npm start
# Only shows errors by defaultFor production with critical events:
NODE_ENV=production LOG_LEVEL=CRITICAL npm start
# Shows errors + critical lifecycle eventsFor debugging in development:
LOG_LEVEL=DEBUG npm start
# Shows everythingFor debugging in production (temporary):
NODE_ENV=production LOG_LEVEL=INFO npm start
# Override production defaults for troubleshooting