Command Syntax
Logging Options Reference
File to redirect log output. By default, logs are written to stdout.Examples:
The log file can be rotated using the
reopen signal. See Signals for details.Timestamp log entries. Enabled by default.Examples:With timestamps:Without timestamps:
Log to syslog or Windows event log. Routes log output to the system’s logging facility.Examples:
Syslog server address. Send logs to a remote syslog server.Format:
udp://hostname:portExamples:Enable debugging output. Provides detailed information about server operations.Examples:Debug output includes:
- Client connections and disconnections
- Subscription details
- Route and gateway connections
- Internal server state changes
Trace the raw protocol. Shows the actual NATS protocol messages exchanged with clients (excluding system account).Examples:Trace output example:
Verbose trace. Traces system account as well. Includes all protocol messages including system account traffic.Examples:Use this when debugging system account issues or JetStream internals.
Debug and trace. Convenient combination of debug and trace flags.Examples:
Debug and verbose trace. Combination of debug and verbose trace flags.Examples:
Logfile size limit. When the log file reaches this size, it is automatically rotated.Format: Number with optional unit (B, KB, MB, GB)Examples:When the limit is reached, the current log file is renamed with a timestamp suffix and a new log file is created.
Maximum printable length for traced messages. Limits the payload size shown in trace output.Examples:Useful when tracing messages with large payloads to prevent log file bloat.Output example with limit:
Complete Examples
Development Debugging
Production Logging
Remote Syslog
Protocol Debugging
Full Debug Mode
Production with Info Logging
Log Levels
NATS server uses the following log levels:| Level | Description | Enabled By |
|---|---|---|
ERR | Error messages | Always |
WRN | Warning messages | Always |
INF | Informational messages | Always |
DBG | Debug messages | -D or --debug |
TRC | Protocol trace | -V or --trace |
Log Rotation
Logs can be rotated in two ways:- Automatic rotation - When
--log_size_limitis reached - Manual rotation - Send
reopensignal to the server
Related Options
- Server Options - Core server configuration
- Signals - Log rotation and reload signals