#56 The Logger
Learn all about the logger in this episode. See how to send messages to the log and how to customize it.
- mp4Full Size H.264 Video (26.8 MB)
- m4vSmaller H.264 Video (13.7 MB)
- webmFull Size VP8 Video (35.1 MB)
- ogvFull Size Theora Video (37.9 MB)
Thanks for the great screencast! One question though:
config.active_record.colorize_logging = false
There is no way one could find colorize_logging method of active record in API (or is it not a method? Anyway how to find it?). Some time ago colored logging was annoying me under windows and I just couldn't find a way to disable it. (before watching your screeny of course:))
These kind of small things are still keeping me away from diving into rails because I'm afraid of not finding what I'm looking for :(
I don't know about Mongrel but with Webrick you can use "puts" instead of logger.debug to display whatever you like in the Webrick log. This works in plugins, views, controllers, models...I think everywhere =)
@Ekolguy, I don't think it's documented in the API. I learned about it from other sites which talk about customizing Rails.
@art, I don't recommend using puts. This will cause problems when you switch to other web servers (apache or lighty). It messes up the HTTP headers which can cause strange bugs.
@art: I'm not sure if it's the same for the ruby logger but in with log4j using the logger meant that you could send any text to /dev/null so that it didn't take up any CPU time in production. Using puts would remove that benefit unless you'd launch your server and redirect all output to /dev/null explicitely.
Jamis Buck posted about a nice script/console trick that allows you to toggle on ActiveRecord log output -- handy when you want to see the generated sql from an AR query: http://weblog.jamisbuck.org/2007/1/31/more-on-watching-activerecord
@Ryan & Gary: Thanks for the tip. I didn't know that.
You can add tail to windows C:\Program Files\Windows Resource Kits\Tools.. Tail.exe . Thanks Ryan.Great Work!!!!!!!!!!!!!
If anyone is having trouble on Windows I've found a solution:
It uses MSYS that Git comes with to tail the file. This enables coloring and such.
thanks for this.
Does this work under the new versions of Rails? I'm having trouble with it.
Thanks, great stuff!
I find myself coming back again to to your writings only because you have several very great insights and also you have been at this a really long time, that is really inspiring and tells me you understand your stuff. Thanks Ryan.Great Work
Thanks! Great Cast.