From: Joel Pearson Date: 2012-10-04T21:54:18+09:00 Subject: Re: Redirecting $stdout and $stderr streams I don't know where you're headed with this, but this is what I use to create a logfile when I'm not running from a console: begin #Output log orig_std_out = STDOUT.clone #Make a record of the default console output to return to it later $stdout.reopen("Rubylog.txt", "w") #Create / overwrite logfile $stdout.sync = true #Allow interception of console output $stderr.reopen($stdout) #Pass errorserrors to logfile #Do stuff... puts "I'm doing stuff!" rescue puts %Q|Fatal error occurred:\n#{$!}\n\nDebugging Information:\n#{$@}|,"Error" #Logfile output ensure STDOUT.reopen(orig_std_out) #Restore output to console end -- Posted via http://www.ruby-forum.com/.