How do I log a stacktrace to log4j?

Solution Unverified - Updated -

Issue

  • We are using log4j our applicaiton logs. Normal logs are written properly, but when I try to print a stack trace it isn't showing up properly. Here is how we are catching an exception and trying to log the error message:
catch (Exception e) {
    debug("Exception in copying file: " + e.getStackTrace());
} 

And this is what it looks like in our logs:

2013-11-21 17:51:45,854 341901 DEBUG [com.company.package] Exception in copying file: [Ljava.lang.StackTraceElement;@5cd983be

Environment

  • JBoss Application Platform (EAP)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In