{"record":{"id":"0ce28d197660ef96","repo":"hashicorp/nomad","slug":"eventlog-level-must-be-one-of-info-warn-or-error","errorCode":null,"errorMessage":"eventlog.level must be one of INFO, WARN, or ERROR","messagePattern":"eventlog\\.level must be one of INFO, WARN, or ERROR","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command/agent/config.go","lineNumber":1587,"sourceCode":"\tif b.Enabled {\n\t\tresult.Enabled = b.Enabled\n\t}\n\n\tif b.Level != \"\" {\n\t\tresult.Level = b.Level\n\t}\n\n\treturn &result\n}\n\n// Validate validates the eventlog configuration\nfunc (e *Eventlog) Validate() error {\n\tif e == nil {\n\t\treturn nil\n\t}\n\n\tif winsvc.EventlogLevelFromString(e.Level) == winsvc.EVENTLOG_LEVEL_UNKNOWN {\n\t\treturn errors.New(\"eventlog.level must be one of INFO, WARN, or ERROR\")\n\t}\n\n\treturn nil\n}\n\n// Ports encapsulates the various ports we bind to for network services. If any\n// are not specified then the defaults are used instead.\ntype Ports struct {\n\tHTTP int `hcl:\"http\"`\n\tRPC  int `hcl:\"rpc\"`\n\tSerf int `hcl:\"serf\"`\n\t// ExtraKeysHCL is used by hcl to surface unexpected keys\n\tExtraKeysHCL []string `hcl:\",unusedKeys\" json:\"-\"`\n}\n\nfunc (p *Ports) Copy() *Ports {\n\tif p == nil {\n\t\treturn nil","sourceCodeStart":1569,"sourceCodeEnd":1605,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/command/agent/config.go#L1569-L1605","documentation":"On Windows, the Eventlog telemetry/log sink accepts only the levels INFO, WARN, and ERROR, mapped via winsvc.EventlogFromString/EventlogLevelFromString. Validate() rejects any other string because the Windows event log API has no finer granularity for this integration.","triggerScenarios":"Config contains an `eventlog { level = ... }` block whose level string does not map to a known winsvc event-log level (e.g. \"debug\", \"trace\", \"notice\", or a typo like \"warnning\") when Eventlog.Validate() runs.","commonSituations":"Copying Unix log-level conventions (debug/trace) into the Windows eventlog block; case or spelling mistakes; assuming the generic log_level values apply to eventlog.","solutions":["Set `level` to exactly one of INFO, WARN, or ERROR (matching is via EventlogLevelFromString, so use the documented casing).","If you need DEBUG-level logging, configure it via the top-level log_level instead of the Windows eventlog sink.","Check for typos such as 'WARNING' where 'WARN' is expected."],"exampleFix":"// before\neventlog {\n  level = \"debug\"\n}\n\n// after\neventlog {\n  level = \"INFO\"\n}","handlingStrategy":"validation","validationCode":"allowed := map[string]bool{\"INFO\": true, \"WARN\": true, \"ERROR\": true}\nif e := cfg.Eventlog; e != nil && !allowed[strings.ToUpper(e.Level)] {\n    return fmt.Errorf(\"eventlog.level must be INFO, WARN, or ERROR, got %q\", e.Level)\n}","typeGuard":"func eventlogLevelValid(l string) bool {\n    switch l {\n    case \"INFO\", \"WARN\", \"ERROR\":\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Only use INFO, WARN, or ERROR in the Windows eventlog block.","Configure debug/trace levels via the general log_level setting instead.","Test Windows-specific config blocks on a Windows host in CI."],"tags":["config-validation","windows","eventlog","logging"],"backgroundTag":"invalid-enum-value","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}