AdguardTeam/AdGuardHome · error
cannot initialize syslog: %w
Error message
cannot initialize syslog: %w
What it means
configureLogger failed to set up syslog output (eventlog on Windows) via aghos.ConfigureSyslog. This occurs when the config's log.file is set to 'syslog' and the platform syslog facility cannot be opened.
Source
Thrown at internal/home/log.go:65
return l
}
// configureLogger configures logger output. ls must not be nil.
func configureLogger(ls *logSettings, workDir string) (err error) {
// Make sure that we see the microseconds in logs, as networking stuff can
// happen pretty quickly.
log.SetFlags(log.LstdFlags | log.Lmicroseconds)
// Write logs to stdout by default.
if ls.File == "" {
return nil
}
if ls.File == configSyslog {
// Use syslog where it is possible and eventlog on Windows.
err = aghos.ConfigureSyslog(serviceName)
if err != nil {
return fmt.Errorf("cannot initialize syslog: %w", err)
}
return nil
}
logFilePath := ls.File
if !filepath.IsAbs(logFilePath) {
logFilePath = filepath.Join(workDir, logFilePath)
}
log.SetOutput(&lumberjack.Logger{
Filename: logFilePath,
Compress: ls.Compress,
LocalTime: ls.LocalTime,
MaxBackups: ls.MaxBackups,
MaxSize: ls.MaxSize,
MaxAge: ls.MaxAge,
})View on GitHub (pinned to b41aefbe51)
Solutions
- Install/run a syslog daemon (rsyslog, busybox syslogd) or ensure /dev/log exists and is mounted
- In containers, mount the host journald/syslog socket: -v /dev/log:/dev/log
- Or change log.file in the config from 'syslog' to a real file path
Example fix
# before (yaml.yaml) log: file: syslog # after log: file: /var/log/adguard-home.log
Defensive patterns
Strategy: fallback
Validate before calling
// Before selecting syslog, probe availability:
if ls.File == "syslog" {
if _, err := syslog.Dial("", "", 0, serviceName); err != nil { ls.File = "/var/log/adguardhome.log" }
} Try / catch
if err := configureLogger(...); err != nil {
if strings.Contains(err.Error(), "syslog") { /* fall back to file/stderr logging */ }
} Prevention
- In containers, prefer a file or stderr for logs
- Mount /dev/log when syslog output is required
When it happens
Trigger: Main calling configureLogger with log.file == "syslog" when syslog.Dial fails — syslog daemon not running, /dev/log missing (containers/minimal images), or Windows eventlog source registration fails.
Common situations: Running in Docker/Alpine without a syslog daemon, systemd-journald socket not mounted into a container, or lacking privileges to register the Windows event source.
Related errors
- duplicated values: %v
- unmarshalling json data into aghalg.NullBool: bad value %q
- json duration is nil
- parsing json time: %w
- json time is nil
AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27).
Data as JSON: /api/errors/b3b78537016067fa.
Report an issue: GitHub.