• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception to log file

 
arjun rampal
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi need to stack trace of java exception to log file .how it can done.
simple messages i am able to send in log file but how to send complete stack trace of exception
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need a stack trace?

exception.printStackTrace() should print the stacktrace to the System.out log. Is this not adequate? exception.getClass() exception.getMessage() and exception.printStackTrace() should do it.

I have a feeling you were looking for something a little more in depth. Let me know.

-Cameron McKenzie
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi need to stack trace of java exception to log file


Assuming you are using log4j, log4j has overloaded methods to which you can pass the entire exception object and it will print the exception stacktrace in the appropriate log file. Something like:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic