Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0
Hi All,
 
How to handle exception properly ?
Let say I am logging exception details to a text file on exception.But while writing exception details if file path not exist/some other exception occur how can I manage it.
 
How to handle exception if it happens in exception logging method.
 
Thanks
Posted 15-Apr-13 2:55am
Comments
Srinivas Lakkapally at 15-Apr-13 7:59am
   
How to handle exception if it happens in exception logging method.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Panic.
 
That's what I generally do.
 
What I actually do is work on the principle that something has gone seriously wrong if I can't log errors - so the chances are that it's not really my problem - it's a major system fault that I have no control over. So ignore it. Report it to the user so they have a chance to save any data elsewhere if you can, or kill your application. If you can't log an error, then you can't log the fact that there is an error (for example, the disk may be full) so there isn't a lot you can do. If for example the disk is full, then you can't even send yourself an email to let yourself know, because that needs temporary disk space at the email system!
  Permalink  
Comments
Marcus Kramer at 15-Apr-13 9:40am
   
+5. I agree completely. If logging itself has failed then there is a much bigger, more serious issue in play than the application alone. (And why I dislike flat file logging as a default mechanism)
OriginalGriff at 15-Apr-13 10:28am
   
Agreed - I generally try to a use a DB as at least it is on a different PC (most of the time)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 Afzaal Ahmad Zeeshan 170
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,777
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 15 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100