I am using Rails 3.2.12 / Ruby 1.9.3 and am trying to configure several logs so that I can log both files and the graylog server we created. I have a close use of this soltuion, but with the Gelf logger - http://railsware.com/blog/2014/08/07/rails-logging-into-several-backends/
So, I returned the port ActiveSupport::Loggerto my config / initializers and configured the gelf logger as below
(development.rb)
gelf_logger = GELF::Logger.new("greylogserver", 12201, "WAN", { :host => 'host', :facility => "railslog"})
Rails.logger.extend(ActiveSupport::Logger.broadcast(gelf_logger))
however i find that i only get errors registered on graylog server
ArgumentError: short_message is missing. Options version, short_message and host must be set.
and when I debug the code, I see that the arguments passed to the Gelf Logger method add(below) always have the 1st element as a level, the second as zero, and the third contains a message. This is confusing because the second argument should be a message and the third should be predictive. The only solution I came up with is to change the Gem-Rb Gem (as shown below) by changing the 6th line to use args [1] for the message, then it works, however it is not perfect, and there should be a way to fix it in my code.
def add(level, *args)
raise ArgumentError.new('Wrong arguments.') unless (0..2).include?(args.count)
message, progname = if args.count == 2
[args[1], args[1]]
elsif args.count == 0
[yield, default_options['facility']]
elsif block_given?
[yield, args[0]]
else
[args[0], default_options['facility']]
end
....
Just to note, when I directly install my Rails registrar to use the Gelf registrar in development.rb, then it works fine
Rails.logger = GELF::Logger.new("greylogserver", 12201, "WAN", { :host => 'host', :facility => "railslog"})
ActiveSupport::Logger, - https://github.com/rails/rails/blob/6329d9fa8b2f86a178151be264cccdb805bfaaac/activesupport/lib/active_support/logger.rb