Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to supress Runtime Exceptions

 
Venkat Raman Parasuraman
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
M K Rayapudi
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
change the log level.
 
Venkat Raman Parasuraman
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please tell me how?? I mean example..Please
 
M K Rayapudi
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have clean running code that doesn't cause Exceptions. ;)

Mark
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Catch Hibernate exceptions in the service layer and re-throw them as application-specific exceptions.
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Venkat Raman Parasuraman
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. I dont want ObjectNotFoundException in the AOP log file. It must be suppressed not being written anywhere
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic