That's because you're handling the exception.
But its logging the error one time for the below case. That's because you're handling the exception: Class1: public void func() { try{ new Class2.prop() }catch(IOException ioe){ logger. Log(2,ioe); } } Class2 : public void prop() throws IOException { try{ //error oocurs here }catch(FileNotFoundException fe){ logger.
Log(2,fe); throw fe; } // Here! } In your catch block of the class2 ( after your //error oocurs here ) you log the exception, that's what you've got on your logs. But since you are just logging the exception, you're telling the program that the exception has been controlled somehow, or handled ( which is more appropriate) and the program continues it's flow to the line where I added the comment // Here!
Later in class1, since the exception was handled, nothing happens in your try/catch block and your second exception is never logged ( as you expected ) because it never happened. If you want to see two logs ( which I think it's unnecessary ) you should re-throw the exception as I did in your class2 and plus, modify the method signature to mark indicate it throws an IOException. That way you will have two logs.
Better will be like this: Class1: public void func() { try{ new Class2.prop() }catch(IOException ioe){ logger. Log(2,ioe); } } Class2 : public void prop() throws IOException { //error oocurs here } In class 2 you don't handle the exception, you just let it go through the caller. In the stacktrace you'll have the information anyway.
I hope this helps.
See the case1 . First it logs error when error occurs in class2. After whecontrol goes to class1 its again logging the same log again.So totally two times log has been logged.
I don want to log same error twice. Tell me howto resolve the case1 n don't have problem in case2. – raja Feb 12 '09 at 6:53 Oscar has given you exactly the right answer: don't log in prop.
Only do it in func(). Let the exception just propagate from prop() to func(). – Jon Skeet Feb 12 '09 at 7:31.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.