-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hi,
I'm having trouble disposing of a custom ILogger that uses an ObservableSink.
I have a custom wrapper that holds an ILogger property. In the setter I'm calling dispose when setting it to null.
What's happening though, is a System.ObjectDisposedException is raised, by the ObservableSink.Unsubscribe method. If I understand the source correctly this means the sink has already been disposed.
Here's the error:
System.ObjectDisposedException: The Serilog Observable sink is disposed.
at Serilog.Sinks.Observable.ObservableSink.Unsubscribe(IObserver1 observer) at Serilog.Sinks.Observable.ObservableSink.Unsubscriber.Dispose() at System.Reactive.Disposables.StableCompositeDisposable.Binary.Dispose() at System.Reactive.Disposables.SingleAssignmentDisposable.Dispose() at System.Reactive.Sink1.Dispose()
at System.Reactive.Disposables.SingleAssignmentDisposable.Dispose()
at System.Reactive.Disposables.StableCompositeDisposable.Binary.Dispose()
at System.Reactive.Disposables.SingleAssignmentDisposable.Dispose()
at System.Reactive.Sink1.Dispose() at System.Reactive.Disposables.SingleAssignmentDisposable.Dispose() at System.Reactive.Disposables.StableCompositeDisposable.Binary.Dispose() at System.Reactive.AnonymousSafeObserver1.OnCompleted()
at System.Reactive.Linq.ObservableImpl.Do1._.OnCompleted() at System.Reactive.Concurrency.ObserveOn1.ObserveOnSink.OnCompletedPosted(Object ignored)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
Am I (I'm assuming I am) doing something in the wrong order here?
I've attached a LinqPad query the demos the problem.
Can anyone shed any light on this please?
Best regards
John
[Background fyi - I've looked at a number of options for multiple loggers / sub-loggers etc. This implementation is intended as a standalone logger (to support different min log levels) that will output events to an ObservableCollection and be surface in a WPF window.]