Rails Broadcasting log to Graylog Does not work

(Tessy Joseph John) #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)

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)

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

(Tessy Joseph John) #2

I fixed this. Instead of lograge I used a gem log4r and gem ‘log4r-gelf’. log4r is perfect for multiple output destination per log.

This is how I did it