Quantcast
Channel: Teach Me To Code » Ruby on Rails
Viewing all articles
Browse latest Browse all 34

Print Debug Information to Its Own Log

$
0
0

Setting up a Debug Log

Have you ever been debugging your Rails application and watching the development log fly by wishing that you could put output just the information you need to its own log? There’s actually a quick and easy way to do it.

First, you create your logger.

@debug_log = Logger.new(File.open(File.dirname(__FILE__) + "/../../log/debug.log", "w"))

Then you log data to it.

@debug_log.debug @object

It’s simple and it makes the data extremely easy to find. Just take the statements out when you’re done debugging.


Viewing all articles
Browse latest Browse all 34

Trending Articles