Log a stack trace

Hi,

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

Thanks

Aidy

On Aug 26, 12:32 pm, aidy [email protected] wrote:

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

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")}

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs