Skip to content

Log

The log block configures sing-box's logger: severity, where to write, whether to include a timestamp, and whether to disable logging entirely.

Options

FieldTypeDefaultAllowed valuesDescription
disabledboolfalsetrue | falseWhen true, sing-box installs a no-op log factory. Nothing is written anywhere, regardless of other fields.
levelstringtracetrace | debug | info | warn | warning | error | fatal | panicMinimum severity. An empty string is treated as the default. The keywords "warn" and "warning" are accepted aliases.
outputstring(stderr)<empty> | stderr | stdout | <file path>Where to write log lines. Empty defaults to stderr; "stderr" and "stdout" are the literal stream names; any other value is treated as a file path.
timestampboolfalsetrue | falseWhen true, every line is prefixed with a timestamp like "-0700 2006-01-02 15:04:05". Required for the timestamp to appear in file output.

Source: option/options.go:40-46 · pinned at v1.13.11 (553cfa1)

Examples

Default behavior (file omits log entirely — equivalent to {}):

json
{
  "log": {}
}

Quiet sing-box for a deployment:

json
{
  "log": {
    "level": "warn",
    "timestamp": true,
    "output": "/var/log/sing-box.log"
  }
}

Disable logging entirely:

json
{
  "log": {
    "disabled": true
  }
}

Notes

  • The default level when level is left empty is trace (the most verbose tier), not info — see log/log.go:67-69. Most production configurations should set level explicitly.
  • output of "stderr" and "stdout" are literal stream names; any other non-empty value is treated as a file path (log/log.go:32-45).
  • When writing to a file, colors are forced off and timestamps are forced on regardless of the timestamp setting — see the formatter setup at log/log.go:46-52.

Source: option/options.go:40-46 · v1.13.11 (553cfa1)

Core Tutorial by Argsment