aspose file tools*
The moose likes Java in General and the fly likes How to capture java.lang.Error in log files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to capture java.lang.Error in log files" Watch "How to capture java.lang.Error in log files" New topic
Author

How to capture java.lang.Error in log files

joe nesbitt
Greenhorn

Joined: Dec 05, 2009
Posts: 17
Hi all,

I have a standalone java enviornment with robust exception handling and the application is well tested.

But some times the process flow is not behaving the way it is expected.
Thus I would want to keep track of anything abnormal that might be happening by looking at the log files. I am thinking that log4j configuration might not help me to log the occurence of the java.lang.Error subclasses.

Similar to the .out files in weblogic enviornment which logs everything that happens in the JVM including the occurence of any java.lang.Error (like stackoverflow/outofmemoryerror), is there a way to capture such errors when occured in a standalone/non-J2EE enviornment?

Any help is appreciated.

Thanks in advance for your time and input.

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

I am thinking that log4j configuration might not help me to log the occurence of the java.lang.Error subclasses.

Why ? log4j can log any java.lang.Throwable, java.lang.Error included.

is there a way to capture such errors when occured in a standalone/non-J2EE enviornment?

If you catch them at your program's entry point, yes. These are usually unrecoverable errors though, so even if you log the error, it might not be a good idea to continue as if nothing happened.


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to capture java.lang.Error in log files