{"record":{"id":"b3b78537016067fa","repo":"AdguardTeam/AdGuardHome","slug":"cannot-initialize-syslog-w","errorCode":null,"errorMessage":"cannot initialize syslog: %w","messagePattern":"cannot initialize syslog: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/home/log.go","lineNumber":65,"sourceCode":"\treturn l\n}\n\n// configureLogger configures logger output.  ls must not be nil.\nfunc configureLogger(ls *logSettings, workDir string) (err error) {\n\t// Make sure that we see the microseconds in logs, as networking stuff can\n\t// happen pretty quickly.\n\tlog.SetFlags(log.LstdFlags | log.Lmicroseconds)\n\n\t// Write logs to stdout by default.\n\tif ls.File == \"\" {\n\t\treturn nil\n\t}\n\n\tif ls.File == configSyslog {\n\t\t// Use syslog where it is possible and eventlog on Windows.\n\t\terr = aghos.ConfigureSyslog(serviceName)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot initialize syslog: %w\", err)\n\t\t}\n\n\t\treturn nil\n\t}\n\n\tlogFilePath := ls.File\n\tif !filepath.IsAbs(logFilePath) {\n\t\tlogFilePath = filepath.Join(workDir, logFilePath)\n\t}\n\n\tlog.SetOutput(&lumberjack.Logger{\n\t\tFilename:   logFilePath,\n\t\tCompress:   ls.Compress,\n\t\tLocalTime:  ls.LocalTime,\n\t\tMaxBackups: ls.MaxBackups,\n\t\tMaxSize:    ls.MaxSize,\n\t\tMaxAge:     ls.MaxAge,\n\t})","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/log.go#L47-L83","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before (yaml.yaml)\nlog:\n  file: syslog\n\n# after\nlog:\n  file: /var/log/adguard-home.log","handlingStrategy":"fallback","validationCode":"// Before selecting syslog, probe availability:\nif ls.File == \"syslog\" {\n    if _, err := syslog.Dial(\"\", \"\", 0, serviceName); err != nil { ls.File = \"/var/log/adguardhome.log\" }\n}","typeGuard":null,"tryCatchPattern":"if err := configureLogger(...); err != nil {\n    if strings.Contains(err.Error(), \"syslog\") { /* fall back to file/stderr logging */ }\n}","preventionTips":["In containers, prefer a file or stderr for logs","Mount /dev/log when syslog output is required"],"tags":["go","logging","syslog","containers","configuration"],"backgroundTag":"syslog-initialization-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}