Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StacktraceElement with timestamp

StackTrace gives class, method, line number in source file.

Is there a way to get the time stamp at which the method executed as well?

like image 573
Nageswara Rao Avatar asked May 29 '26 01:05

Nageswara Rao


1 Answers

I don't thnik so since the API doesn't give you access to a timestamp. Neither the Exception nor the StatckTraceElement API.

You can use logging (e.g. wtih log4j) and log the exception. A log record can print out the timestamp of the log record. Of cource this is the timestamp when the record was logged and not when the exception ocurred, but if you log immediatly after an exception it should not make a big difference.

like image 113
René Link Avatar answered May 30 '26 16:05

René Link



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!