NetEscapades.Extensions.Logging
NetEscapades.Extensions.Logging copied to clipboard
Generic Host Builder calls Dispose on LoggerFactory
HostBuilder is now calling Dispose on its ILoggerFactory after building all the loggers (a bug fix I think) which is in turn disposing the BatchingLoggerProvider which is stopping the logging at startup - so, it no longer works.
The glass is cloudy but I think you have to pass a factory to the ILoggerFactory instead of letting it build the class automagically, so something like: builder.Services.AddSingleton<ILoggerProvider, FileLoggerProvider>(factory => { return new FileLoggerProvider(); }); instead of: builder.Services.AddSingleton<ILoggerProvider, FileLoggerProvider>();
Because if you build it YOURSELF, then Dispose doesn't get called by the container... But the first doesn't work because of options....
Dispose doesn't get called by the container Which confusingly seems to be the container of the ILoggerFactory, not the Host Container. When you do it this way the LoggerProvider still gets Disposed by the Host Container... I think there are multiple containers.