In my java code, when an exception occurs, I want to print my specified message to the console and write its stack trace to the log file at the same time. How can I do it? What I want to do is like following;
try {
//do something
} catch (Exception e) {
logger.error("Exception occured."); //print console "Exception occured
logger.error("Exception occured", e); //write entire stack trace to log file
}