Initializer is using wrong Logger base class
uberllama opened this issue · comments
I found that Rails.logger.silence
blocks fail when using this gem. The issues seems to be that RemoteSyslogLogger.new
instantiates aLogger
, when it should be instantiating an ActiveSupport::Logger
. Reference: https://stackoverflow.com/a/38361137
Here's a hacky workaround I've been using:
in config/production.rb
RemoteSyslogLogger::Logger = ActiveSupport::Logger
It works because Logger
being used within the RemoteSyslogLogger
module here:
RemoteSyslogLogger::Logger
is typically undefined and the name resolves to ::Logger
, but my hack defines it.
Here's a hacky workaround I've been using:
in
config/production.rb
RemoteSyslogLogger::Logger = ActiveSupport::LoggerIt works because
Logger
being used within theRemoteSyslogLogger
module here:
RemoteSyslogLogger::Logger
is typically undefined and the name resolves to::Logger
, but my hack defines it.
Thanks Mike! I'll stash this for later. We ended up being able to switch back to the Rails standard logger sending to STDOUT, and having the container do the remote syslogging. One less third party dependency.
We ended up being able to switch back to the Rails standard logger sending to STDOUT, and having the container do the remote syslogging.
I'm interested in switching to this. Can you write up some details or link to a guide?
Hey Mike,
I'll try and get up a technical post at some point, but effectively here is what we did at a high level.
- Created a custom entrypoint sh file that basically takes the output of the script and sends it to syslog. This can be done using something like the following command
exec 1> >(logger -s -t $(basename $0)) 2>&1
- Configured rsyslog to forward our logs to papertrail. So, installed rsyslog, ensured the webapp user could configure a forward.conf file (environment specific logging destinations), and initialized/started rsyslog as part of the entrypoint script above.
Hope that helps. Feel free to ask more if required.