English
log — the log
yaml
log:
level: info
output: /var/log/ours.log
timestamp: true| Field | Meaning | Default |
|---|---|---|
level | trace, debug, info, warn, error | info |
output | stderr, stdout or a path to a file (appended to) | stderr |
format | text or json (one object per line) | text |
timestamp | Print the time (UTC) on every line | true; on stderr under systemd (JOURNAL_STREAM), false: the journal adds the time |
disabled | Turn the log off | false |
warningis the same aswarn;fatalandpanicare the same aserror.- Text logs use color on terminals. JSON logs use plain text on every output.
- The section also applies on reload. The level, format and output can be changed without restarting.
- An unknown level or format is an error of
check, startup or reload.
With format: json, each event has level, fields and, when enabled, timestamp. Connection details such as addresses and the connection ID can still be part of fields.message:
json
{"level":"INFO","fields":{"message":"[12] rejected by rule[3]"}}For a service managed by systemd, leave output at stderr and use journald for retention. For a file, configure external rotation. After renaming it, send SIGUSR1 to reopen the active log path, for example with systemctl kill --kill-who=main --signal=SIGUSR1 ours in a logrotate postrotate script. If reopening fails, ours keeps writing to the previous file.
FATAL … messages about a failed start are printed to stderr regardless of the section.
What goes to the log:
- The first line is the build:
ours 0.1.0 (<commit>, <date>, <target>) starting; on a stop by signal,ours stopping (SIGTERM)andours stopped. A log without these lines ended some other way. - The lines of one connection start with its number:
[12] inbound/trojan[in]: [alice] inbound connection from … to …(the user name is on the same line),[12] outbound/…,[12] rejected by rule[3]— rejected by the rule with this number inroute.rules. - A connection the inbound closed before routing (a failed TLS handshake, a wrong password, a scanner, a visitor of the REALITY cover site) is written at
debug; atinfo, the first one per minute per inbound, with the number of the others:… process connection from …: … (41 more refused since the last such line; debug logs each). The counter isours_inbound_refused_total(metrics). - A panic (a bug in ours) is written as
ERROR panic in thread … at <file>:<line>: …with the version and commit, to the configuredoutput, and if that is not stderr, to stderr as well. A panic in a connection closes only that connection; any other panic stops the process the same way asSIGTERM(theauto_nftinterception is removed), with exit code 1 and a backtrace in the log. A backtrace of a connection panic needsRUST_BACKTRACE=1.
With the dashboard on (--dashboard or admin.listen) the last 256 log records (not below the configured level) are visible in the Events section of the Dashboard.