I am writing an error logging set of classes which will log to file, event log etc. What exception handling should be performed within these classes? For instance, say I have a LogError method, which is called from exception handlers, and writes to file. What is considered the best thing to do, should an error occur? Obviously, I should make these methods as fail safe as possible, but problems can always occur.
Share
Generally I output to stderr as much information as possible in that case, often both the error/exception in the logging code, and the original log/error/exception. That way there’s a chance of reproducing the problem or understanding it.
If writing to stderr fails then it’s time to give up – either ignore it, to terminate the application entirely.