Possible Duplicate:
How do I in java add a stacktrace to my debugging printout
What's the best way to include the stack trace in log4j's output when there's not an exception? The only way I can think of is to create a new Exception
instance.
log.error("description", new Exception());
Follow-up: I am fully aware of Thread.currentThread().getStackTrace()
and Thread.dumpStack()
. These output to the console, which in many environments are separate from the log4j output. What I'm looking for a way to log the stack trace to log4j, and not the console.