Log a stack trace

Hi,

Is it possible to log a stack trace to a text file?

Thanks

Aidy

Yes: Raise an exception.

def backtrace
  begin
    fail
  rescue Exception => e
    return e.backtrace[1..-1]
  end
end

File.open("backtrace.txt", "w") do |f|
  f.puts backtrace
end

Lars

···

On Aug 26, 12:32 pm, aidy <aidy.le...@googlemail.com> wrote:

Is it possible to log a stack trace to a text file?

aidy wrote:

Hi,

Is it possible to log a stack trace to a text file?

Thanks

Aidy

File::open("file","w"){|f| f<<caller.join("\n")}

···

--
Posted via http://www.ruby-forum.com/\.