Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make agent syslog log level inherit from Nomad agent log #15625

Merged
merged 4 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/15625.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
agent: Make agent syslog log level follow log_level config
```
15 changes: 13 additions & 2 deletions command/agent/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,21 @@ func SetupLoggers(ui cli.Ui, config *Config) (*logutils.LevelFilter, *gatedwrite

// Create a log writer, and wrap a logOutput around it
writers := []io.Writer{logFilter}

dttung2905 marked this conversation as resolved.
Show resolved Hide resolved
logLevel := strings.ToUpper(config.LogLevel)
logLevelMap := map[string]gsyslog.Priority{
"ERROR": gsyslog.LOG_ERR,
"WARN": gsyslog.LOG_WARNING,
"INFO": gsyslog.LOG_INFO,
"DEBUG": gsyslog.LOG_DEBUG,
"TRACE": gsyslog.LOG_DEBUG,
}
if logLevel == "OFF" {
config.EnableSyslog = false
}
// Check if syslog is enabled
if config.EnableSyslog {
l, err := gsyslog.NewLogger(gsyslog.LOG_NOTICE, config.SyslogFacility, "nomad")
ui.Output(fmt.Sprintf("Config enable_syslog is `true` with log_level=%v", config.LogLevel))
l, err := gsyslog.NewLogger(logLevelMap[logLevel], config.SyslogFacility, "nomad")
if err != nil {
ui.Error(fmt.Sprintf("Syslog setup failed: %v", err))
return nil, nil, nil
Expand Down
3 changes: 2 additions & 1 deletion website/content/docs/configuration/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ testing.
diagnostic information about Nomad's internals.

- `enable_syslog` `(bool: false)` - Specifies if the agent should log to syslog.
This option only works on Unix based systems.
This option only works on Unix based systems. The log level inherits from
the Nomad agent log set in `log_level`

- `http_api_response_headers` `(map<string|string>: nil)` - Specifies
user-defined headers to add to the HTTP API responses.
Expand Down