Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wrap error trace inside Log.Severe()

I am using java.util.logging.Logger for logging on app-engine. Normally all I have to do to get my errors is to call e.printStackTrace(). Except I get nothing when I make the call from inside a worker thread that belongs to a Task Queue. But within the Task Queue, all the loggings done with LOG.info() are showing. So my question is: how do I wrap a stack trace inside LOG.severe()? The following shows the address instead of the trace itself:

private static final Logger LOG = Logger.getLogger(LuceneWorker.class.getName());

//later inside a method
LOG.severe(e.getStackTrace().toString());
like image 982
Katedral Pillon Avatar asked Mar 01 '26 21:03

Katedral Pillon


1 Answers

Logger#severe(msg) is just a convenience method for Logger#log(Level.SEVERE, msg) Use that method instead.

LOG.log(Level.SEVERE, "Your Log Message", e);
like image 93
pathfinderelite Avatar answered Mar 03 '26 12:03

pathfinderelite



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!