I'm currently setting up my Rails (3.2 at this point, though it runs under 4.1 on a dev branch) app to ship its logs to a centralized Graylog2 log aggregation server using the lograge and gelf-rb gems. The config (in the environment file) looks like:
config.lograge.enabled = true
config.lograge.log_format = :graylog2
config.logger = GELF::Logger.new("log1.example.com", 12201, "WAN", { :host => "dev", :facility => "rails" })
This all works great for the "main" 200 OK log message associated with each request. The problem is that my controller code has other logger.info, logger.warn, etc... scattered around the codebase. Each of these messages is logged as a separate GELF message info Graylog2.
What I'd like to see happen is that all the log messages for a single HTTP request are bundled together into a single log message in Graylog2 rather than having a whole bunch of isolated log messages unconnected with their associated HTTP requests. In other words, the lograge output, plus all the logger.* calls, for each HTTP request should together form a single log line that graylog2 can manage.
What am I missing here? It seems like this shouldn't be an uncommon need, but I'm not seeing anything that doesn't involve me writing yet another custom logger.