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

Initializer is using wrong Logger base class #29

Open
uberllama opened this issue Dec 4, 2019 · 4 comments
Open

Initializer is using wrong Logger base class #29

uberllama opened this issue Dec 4, 2019 · 4 comments

Comments

@uberllama
Copy link

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

@mikegee
Copy link

mikegee commented Jan 6, 2020

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:

Logger.new(RemoteSyslogLogger::UdpSender.new(remote_hostname, remote_port, options))

RemoteSyslogLogger::Logger is typically undefined and the name resolves to ::Logger, but my hack defines it.

@uberllama
Copy link
Author

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:

Logger.new(RemoteSyslogLogger::UdpSender.new(remote_hostname, remote_port, options))

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.

@mikegee
Copy link

mikegee commented Jan 7, 2020

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?

@CtrlDot
Copy link

CtrlDot commented Jan 7, 2020

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.

rapito added a commit to rapito/remote_syslog_logger that referenced this issue Nov 24, 2020
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

3 participants