This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Spring and the fly likes How to supress Runtime Exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to supress Runtime Exceptions" Watch "How to supress Runtime Exceptions" New topic
Author

How to supress Runtime Exceptions

Venkat Raman Parasuraman
Greenhorn

Joined: Oct 13, 2008
Posts: 10
Hi,

In hibernate, when the object is not found, then it throws a Runtime exception which is not needed for me. How can we stop logging the RuntimeException alone.

Thanks,
Venkat


Thanks,
Venkat
M K Rayapudi
Ranch Hand

Joined: Feb 19, 2007
Posts: 157
change the log level.


R6i
Venkat Raman Parasuraman
Greenhorn

Joined: Oct 13, 2008
Posts: 10
can you please tell me how?? I mean example..Please
M K Rayapudi
Ranch Hand

Joined: Feb 19, 2007
Posts: 157
You might be configuring logging tool using a properties file.
For e.g. Log4j.properties
in that properties file change log level to fatal where ever you find debug/info/warn/error

Note: By changing the log level to fatal may suppress other messages also


Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Have clean running code that doesn't cause Exceptions. ;)

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Catch Hibernate exceptions in the service layer and re-throw them as application-specific exceptions.
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
I don't know what you mean by "stop logging", you mean you don't want ObjectNotFoundException to appear in log or something else? If so why do you want to do that?


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Venkat Raman Parasuraman
Greenhorn

Joined: Oct 13, 2008
Posts: 10
Yes. I dont want ObjectNotFoundException in the AOP log file. It must be suppressed not being written anywhere
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
Venkat Raman Parasuraman wrote:Yes. I dont want ObjectNotFoundException in the AOP log file. It must be suppressed not being written anywhere

Actually, it's good to have ObjectNotFoundException (or any exceptions) appears in the log file.
But if you really don't want...

I don't know how do you implement this AOP logging, but when an exception is thrown eventually some code will catch it, right? I imagine that the code (AOP or not) that catches it will log this exception, so can you add code to check that if type of the exception is ObjectNotFoundException then not log it?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to supress Runtime Exceptions