log a stack trace

L

Lars Christensen

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top