1

I want to forward all logs to graylog server plus I want to maintain my actual Rails Log. I am using ruby gelf gem. https://github.com/Graylog2/gelf-rb and lograge. In my application.rb I have the code

if Rails.env.in? ['production', 'preproduction', 'staging']
    config.lograge.keep_original_rails_log = true
    config.lograge.logger =  GELF::Logger.new(graylog.example.in", 12219)
end

With This I am getting all the request and response in the graylog server.But I does not sent the explict logging logged like these

Rails.logger.info "#{params}"

So I added this code in application.rb

  gelf = GELF::Logger.new("graylog.example.in", 12219)
  config.logger.extend(ActiveSupport::Logger.broadcast(gelf))

This works from rails console.But does not sent from the application

tessie
  • 964
  • 3
  • 14
  • 24

1 Answers1

0

Logging to multiple output destination is pretty simple by using log4r gem https://github.com/colbygk/log4r. To forward to the remote graylog you might also need to gem 'log4r-gelf'

tessie
  • 964
  • 3
  • 14
  • 24