Serilog example fixed #1
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check out the change in Program.cs.
Dotnettency depends upon Microsoft.Extension.Logging.ILogger to be injected, so microsoft logging must be added and configured prior to startup. Serilog has some docs that show you how it can hook up with microsofts abstraction so it can support this scenario.. but I found the mechanism suggested in the serilog readme a little problematic.
UseSerilog()
(in Program.cs) causes the problem withdotnettency
seemingly because it relies on a constructedIServiceProvIder
instance, to then find all the registeredILogger's
(microsoft ones) and set up it's own factory. Trouble is needs that factory to be registered ahead of the IServiceProvider being constructed. This is because the implementation of theIServiceProvider
that get's constructed is actually dotnettency's `IServiceProvider implementation - and in it's constructor it requires an ILogger to be injected - which requires a ILoggerFactory to be registered. However Serilog registers it's own ILoggerFactory that requires an IServiceProvider to be created first.. and thus the recursive loop that Autofac was complaing about..Anyway alternative way of registering serilog seems to work nicely.
Sorry about the noise in this PR, I also updated the dotnettency dependencies to use the latest 2.0.0-alpha version from dev branch.