Logging Configuration
Gate uses structured logging with Uber’s Zap logger, providing high-performance, leveled logging with structured fields. Logs can be configured via command-line flags and environment variables.Log Levels
Gate supports multiple log verbosity levels, controlled by the--verbosity flag or GATE_VERBOSITY environment variable:
| Verbosity | Level | Use Case |
|---|---|---|
0 | Info | Production (default) - Essential operational messages |
1 | Debug | Development - Detailed debugging information |
2+ | Trace | Deep debugging - Very detailed internal operations |
Setting Log Level
Configuration
Command-Line Flags
Environment Variables
Configuration File
Log Format
Gate uses different log formats depending on the mode:Production Format (Default)
JSON-structured logs optimized for machine parsing:Development Format (Debug Mode)
Human-readable console logs with colors:Logger Implementation
Gate’s logger is configured incmd/gate/root.go:191:
Structured Fields
Gate logs include structured fields for easy filtering:OpenTelemetry Integration
When OpenTelemetry tracing is enabled, logs automatically include trace context:Log Aggregation
Grafana Loki
Loki is designed for aggregating logs from multiple sources.Docker Compose with Loki
Loki Configuration
Querying Logs in Grafana
Promtail for Log Shipping
Use Promtail to ship logs from files to Loki:Elasticsearch and Kibana
For Elasticsearch-based log aggregation:Best Practices
1. Production Logging
- Service startup/shutdown
- Player connections/disconnections
- Configuration changes
- Errors and warnings
2. Development Logging
- Detailed packet information
- Authentication flows
- Internal state changes
- Performance metrics
3. Structured Fields
Always use structured fields instead of string formatting:4. Log Sampling
For high-frequency events, use sampling to reduce log volume:5. Sensitive Data
Never log sensitive information:6. Error Context
Include context when logging errors:Log Rotation
Using logrotate (Linux)
Using Docker logging driver
Custom Plugin Logging
Use the context logger in your plugins:Troubleshooting
No Logs Appearing
-
Check verbosity level:
-
Ensure debug mode is not disabled in config:
- Verify logger initialization in Gate startup logs
Too Many Logs
-
Reduce verbosity:
-
Disable debug mode:
- Implement log sampling for high-frequency events
Logs Not in JSON Format
Gate uses console encoding by default. For JSON logs, you need to modify the logger configuration or use a log shipper to parse console logs.Next Steps
OpenTelemetry
Set up comprehensive observability
Metrics
Monitor proxy performance metrics

