For a Ruby on Rails project, I am using a cloud-based logger, Loggly, but I also need to have physical logs on the server somewhere I can tail or look at if something goes wrong higher up in the stack (before the logging to Loggly gets initialized, I'm guessing; the site is clearly down right now but shows nothing in loggly about that). Is it possible to have Rails log both to Loggly and also to files in the standard way, and have identical content logged to both?
Asked
Active
Viewed 418 times
4
-
Have you tried the standard Rails logger (e.g. Rails.logger.debug) along side Loggly? Something like `def dual_logger(msg) Rails.logger.info(msg)
Loggly.log(msg) [or whatever the syntax] end`? – ScottJShea Feb 15 '12 at 04:54 -
Sorry, expanding on that thought again you would likely need to wrap a logging module around Loggly and Rails logger and then specify it in the runtime environments as mentioned here: http://guides.rubyonrails.org/debugging_rails_applications.html#the-logger – ScottJShea Feb 15 '12 at 05:00
-
1That's what I was afraid of having to do. It'll probably have to wait a bit then. My ideal here would be to have remote log tailing like Heroku has, so I could type something like `cap logs:tail` and see my logs, live, in the console. Maybe soon. Thanks though! – max Feb 15 '12 at 20:49
1 Answers
1
I would use log4r. The app just logs once, but, depending on your log4r config, it can dispatch the same log to multiple logs, in multiple formats using multiple protocols. It's a steep learning curve (a la syslog), but worth the effort.

dynex
- 905
- 7
- 8