We use SyslogLogger gem in order to forward rails application log to system log.
in rails Gemfile:
1 2 3 |
|
in config/environments/production.rb
1
|
|
The problem was that logs actually were forwarded to syslog, messages and user.log and sent to remote server and written to syslog, messages and user.log there. I was asked to make things DRY(ier).
The issue was caused, of cource, by some nasty *.* patterns in rsyslog config. If you’re experiencing similar issues, check /etc/rsyslog.d directory which contains rsyslog configuration files. Make sure you have separate config file for your application and it has higher load priority, for example:
1 2 3 4 |
|
rules in 40-rails_application_name.conf will be checked first. Contents of 40-rails_application_name.conf file on rails application server:
1 2 |
|
Note “& ~”, it means log entry will be sent using TCP to your.logging.server.ip.com:61514 and won’t be processed further. This was missing and entries were forwarded to local log files. If you do need to log to the local file, don’t add “& ~”.
rules in 40-rails_application_name.conf file on log server:
1 2 3 4 5 |
|
Now logs are stored correctly.
Here is a complete guide for those who needs more details regarding rsyslog configuration.