From: Brian Cowdery Date: 2006-06-17T00:40:37+09:00 Subject: Re: Capturing STDOUT to a Logger Logan Capaldo wrote: > The other alternative is to set $stdout to your log file, e.g. > > $stdout = File.open("logfile.txt", "w") > > then create the logger for stdout > > logger = Logger.new($stdout) > > This has it's ups and its downs compared to the other method. > > > You don't have to add an IO methods to the logger (puts, print, etc.) > but the stuff written won't be prefixed with the log information. Thanks a million. Just a quick note for anyone else, but it looks like Test::Unit actualy writes directly to STDOUT (look at console/testrunner), he's captured STDOUT as a class viarable @io - so the only way that we can grab all output (errors ect) is by manipulating STDOUT directly... so expanding on the above method: instead of > $stdout = File.open("logfile.txt", "w") use STDOUT.reopen("logfile.txt", "w") then > logger = Logger.new($stdout) -- Posted via http://www.ruby-forum.com/.