I am trying to handle an Enterprise Library 6 LogWriter Exception that has recently popped up after upgrading from Enterprise Library 4 to 6.
I either get:
The LogWriter has not been set for the Logger static class. Set it invoking the Logger.SetLogWriter method.
OR
The LogWriter is already set.
...depending on the scenario.
The problem is that it throws an InvalidOperationException which seems too generic to handle, and that even checking using
if (Logger.Writer == null)
... also yields an exception, so how would one then check if the writer is set or not?
Thanks for the answers and comments.
I have looked through the project's code and seen that there is nothing built into it that supports this.
Even though the project is no longer under development, I took a chance and posted a feature request.
Best scenario to achieve this requirement would
be forkingdownloading it and adding logic that does a check and additionally defining specific exceptions (see feature request):LogWriterNotSetExceptionandLogWriterAlreadySetExceptionEDIT
Struck out forking as that would have licensing implications. Ownership has not been transfered for the Logging Application Block. Only Unity and Prism have been transferred.
According to a comment on the notice about the future of Unity, from a P & P member:
So best bet for anyone working on something new is trying out Semantic Logging