logging a backtrace

S

snacktime

If I catch an exception, is there a way to produce a backtrace that I
can log using something like logger?
 
E

Ezra Zygmuntowicz

If I catch an exception, is there a way to produce a backtrace that I
can log using something like logger?


rescue Exception => e
logger.error "#{ e.message } - (#{ e.class })" << "\n" <<
(e.backtrace or []).join("\n")
end

That is what I use to get a decent looking backtrace

-Ezra
 
S

snacktime

If I catch an exception, is there a way to produce a backtrace that I
can log using something like logger?


rescue Exception => e
logger.error "#{ e.message } - (#{ e.class })" << "\n" <<
(e.backtrace or []).join("\n")
end

That is what I use to get a decent looking backtrace

-Ezra

Thanks, that's just what I was looking for.
 

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
474,211
Messages
2,571,092
Members
47,693
Latest member
david4523

Latest Threads

Top