File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Websphere and the fly likes exception to log file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "exception to log file" Watch "exception to log file" New topic

exception to log file

arjun rampal
Ranch Hand

Joined: Jul 08, 2005
Posts: 125
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

Joined: Aug 26, 2006
Posts: 4968

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

Joined: Jul 20, 2005
Posts: 10441

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:

[My Blog] [JavaRanch Journal]
I agree. Here's the link:
subject: exception to log file
jQuery in Action, 3rd edition