We have some integration tests that we made for a wrapper we created on top of the Logging Application Block.
In some integration tests we need to check different TraceListeners that we created.
We are changing the configuration of the TraceListeners (the mapping of which category is mapped to which TraceListener) at runtime and then call Logger.Reset in order to load the new configuration.
In 4.1 this worked perfectly but when we migrated to 5.0 it suddenly stopped working. When we investigated the problem we noticed that after the call to Logger.Reset() the writer instance that is used by the Logger doesn't changed. (We checked by calling
We took at look at the source code, and narrowed it down to the instantiation of the LogWriter in the Logger class (LogWriter_get): in EntLib 4.1 the object was created through a factory that returned a new instance every time. In 5.0 the container is called,
returning the same instance every time. (Probably has something to do with LoggerSettings.CreateLogWriterRegistration()).
(Also it should be noted that calling Logger.Reset causes the LogWriter to be Disposed, meaning that in 5.0 after calling Reset we'd be using a Disposed LogWriter.)
Is this the desired behavior?
If so, how do we set the logger to write to a specific TraceListener at runtime?