Logging exception stacktrace

Logging standard message is simple

Following are the different ways to log messages using Log4J

  • Log.debug (“Debug Message”);
  • Log.info (“Info Message”);
  • Log.warn (“Warning Message”);
  • Log.error (“Error Message”);

But sometime we need to log exception along with stacktrace, for that we need to use

LOG.log(Level.ERROR, exception.getMessage(), exception);

No special configuration required for this behaviour.

This entry was posted in Java. Bookmark the permalink.

Leave a Reply