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

NGINX logs are logged twice #173

Open
axl89 opened this issue Oct 2, 2020 · 1 comment
Open

NGINX logs are logged twice #173

axl89 opened this issue Oct 2, 2020 · 1 comment

Comments

@axl89
Copy link
Contributor

axl89 commented Oct 2, 2020

Using this cookbook (v7.0.1) with Chef (16.5.77), I get the undesired behavior of NGINX logs getting logged twice in syslog and messages because the way the 35-server-per-host.conf.erb template is written.

According to NGINX docs, by default the severity is set as info, and in the 35-server-per-host.conf.erb template we can find that:

$template PerHostSyslog,"<%= node['rsyslog']['log_dir'] %>/<%= node['rsyslog']['per_host_dir'] %>/syslog"
...
$template PerHostMessages,"<%= node['rsyslog']['log_dir'] %>/<%= node['rsyslog']['per_host_dir'] %>/messages"
...
*.*;auth,authpriv.none  -?PerHostSyslog
...
*.=info;*.=notice;*.=warn;\
  auth,authpriv.none;\
  cron,daemon.none;\
  mail,news.none        -?PerHostMessages

so it matches both PerHostSyslog and PerHostMessages templates.

I've found a workaround in NGINX, which is set the severity to crit so it gets only logged in syslog, but I don't really know if this is OK (my experience with rsyslog and syslog is very limited).

Would it be possible that the server.rb recipe had the source property set via attribute so we can tune it to match our specific needs? E.g:

diff --git a/recipes/server.rb b/recipes/server.rb
index 7ea0e53..0eeb0bc 100644
--- a/recipes/server.rb
+++ b/recipes/server.rb
@@ -30,7 +30,7 @@ directory node['rsyslog']['log_dir'] do
 end
 
 template "#{node['rsyslog']['config_prefix']}/rsyslog.d/35-server-per-host.conf" do
-  source   '35-server-per-host.conf.erb'
+  source   node['rsyslog']['server-per-host-template']
   owner    node['rsyslog']['config_files']['owner']
   group    node['rsyslog']['config_files']['group']
   mode     node['rsyslog']['config_files']['mode']
@axl89
Copy link
Contributor Author

axl89 commented Oct 2, 2020

Leaving NGINX aside, I can replicate the same behavior when doing systemctl stop rsyslog: it gets logged twice in messages and syslog.

Could it be an issue with the 35-server-per-host.conf.erb template, or is this the expected behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant