My question is specific to php, but i think it can be useful in other languages.I log into a table all the exception a code can throw:try{ //Some code } catch (Exception $e) {      $log = new Log(basename($_SERVER['PHP_SELF']), $_SESSION['id'], LogType::EXCEPTION, $e);      try {           $log ->addLog();       } catch (Exception $e2) {                //       } }The function addLog insert the exception informations into a database.But (by example if the connection with the database is lost) this function can throw an exception. I can't see what i have to do with this exception except ignoring it.I know ignoring exception is a bad practice, but what can i do in this particular case?If there is no problem to ignore it, is there a better way to indicate that this exception should not be taken into account?
Exception when logging exception: is it correct to ignore them?
php;exceptions;logging;exception handling
Whatever you do, don't swallow the exception. If something is broken, you need to know about it.  Swallowing an exception is only reasonable in very rare circumstances. When you catch an exception, you should try logging it into a data store (database, event viewer, whatever works for you), so that somebody can then go and look in a single place to see all the exceptions.If logging fails, revert to a simpler logging mechanism that is not dependent on a network resource.  I normally log to a text file and then ask the user to send me a copy of the file.Finally, you should let the user know that something went wrong.  You may choose to display the full stack trace or just a simple error message.  Displaying a full stack trace to the end user is not recommended, as it's a security risk. I normally display a user-friendly message that prompts the end user to contact support. On a side note, I've also seen a logging mechanism where the client would submit error details to the logging service over HTTP. If the service were not available, the client would retry logging three times before failing and reverting to a simpler logging mechanism.