0

My requirement is, I have an application that saves the errors into the database to see later time from the dashboard in my own way. therefore, I want to get the happening errors into string same as the error shows the console. I can the message or other stuff from the error object. but it's not I want. I want to preview the error as the java console shows.

arosh
  • 11
  • 2

1 Answers1

0

you can get by using StringWriter and PrintWriter like this.

StringWriter sw = new StringWriter();
PrintWriter printWriter = new PrintWriter(sw);
yourException.printStackTrace(printWriter);
String errorLogAsString = sw.toString();
Mafei
  • 3,063
  • 2
  • 15
  • 37