I have a situation in which I want to print all the exception caught in catch block using logger.
try { File file = new File(\"C:\\\\className\").mkdir(
You can use this method to log the exception stack to String
public String stackTraceToString(Throwable e) { StringBuilder sb = new StringBuilder(); for (StackTraceElement element : e.getStackTrace()) { sb.append(element.toString()); sb.append("\n"); } return sb.toString(); }