Log
The log block configures Xray's two log streams (access and error) plus optional DNS-query logging and IP-masking.
Options
| Field | Type | Default | Allowed values | Description |
|---|---|---|---|---|
access | string | console | <file path> | none | Where to write access logs. Empty (or unset) writes to the console; "none" disables the access log; any other value is treated as a file path. |
error | string | console | <file path> | none | Where to write error logs. Same semantics as access: empty = console, "none" = off, anything else = file path. |
loglevel | string | warning | debug | info | warning | error | none | Minimum severity for the error log. The value "none" also forces the access log off. |
dnsLog | bool | false | true | false | When true, every DNS query the routing engine resolves is written to the access log. |
maskAddress | string | (off) | full | half | quarter | /v4mask+/v6mask | Mask client/destination IP addresses in the log. "full" = /0+/0, "half" = /16+/32, "quarter" = /8+/16. You can also pass an explicit pair like "/16+/64". |
Source: infra/conf/log.go:18-24 · pinned at v26.6.1 (94ffd50)
Examples
Console output at the default warning level:
json
{
"log": {
"loglevel": "warning"
}
}Write both streams to files, log every DNS query, mask IPs to /16+/32:
json
{
"log": {
"access": "/var/log/xray/access.log",
"error": "/var/log/xray/error.log",
"loglevel": "info",
"dnsLog": true,
"maskAddress": "half"
}
}Turn logging off entirely:
json
{
"log": {
"loglevel": "none"
}
}Notes
- The
accessanderrorfields share an identical "none / empty / path" decision inLogConfig.Build(infra/conf/log.go:36-47); the value"none"is the documented kill switch — any other non-empty string is treated as a file path, not a level keyword. loglevel: "none"is special: it forces both streams off in addition to silencing the error stream (infra/conf/log.go:57-59).maskAddressis not enum-validated at config parse time. Unknown values fall through to the custom-pair parser inapp/log/log.go:177-193, and a parse error there propagates as a startup failure.
Source: infra/conf/log.go:18-24 · v26.6.1 (94ffd50)
