Skip to content

Log

The log block configures Xray's two log streams (access and error) plus optional DNS-query logging and IP-masking.

Options

FieldTypeDefaultAllowed valuesDescription
accessstringconsole<file path> | noneWhere 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.
errorstringconsole<file path> | noneWhere to write error logs. Same semantics as access: empty = console, "none" = off, anything else = file path.
loglevelstringwarningdebug | info | warning | error | noneMinimum severity for the error log. The value "none" also forces the access log off.
dnsLogboolfalsetrue | falseWhen true, every DNS query the routing engine resolves is written to the access log.
maskAddressstring(off)full | half | quarter | /v4mask+/v6maskMask 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 access and error fields share an identical "none / empty / path" decision in LogConfig.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).
  • maskAddress is not enum-validated at config parse time. Unknown values fall through to the custom-pair parser in app/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)

Core Tutorial by Argsment