serilog / serilog-extensions-logging

Serilog provider for Microsoft.Extensions.Logging
Apache License 2.0
309 stars 99 forks source link

Other sections error once serilog added to project #111

Closed T3zler closed 6 years ago

T3zler commented 6 years ago

Hi, Attempting to use serilog. But once the dependencies are added

And the following added:

Log.Logger = new LoggerConfiguration() .ReadFrom.Configuration(Configuration) .CreateLogger();

loggerFactory.AddSerilog();

I get an error when trying to access other config sections.

services.Configure<IpRateLimitOptions>(Configuration.GetSection("IpRateLimiting"));

System.TypeLoadException occurred HResult=0x80131522 Message=Method 'get_Name' in type 'Microsoft.Extensions.Options.ConfigurationChangeTokenSource`1' from assembly 'Microsoft.Extensions.Options.ConfigurationExtensions, Version=1.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation. Source=Microsoft.Extensions.Options.ConfigurationExtensions StackTrace: at Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure[TOptions](IServiceCollection services, IConfiguration config) at NGB.IFS.PurchApp.Services.Startup.ConfigureServices(IServiceCollection services) in C:\Users\saynort\Documents\Repos\ngb.ifs.purchapp\ngb.ifs.purchapp\NGB.IFS.PurchApp.Services\Startup.cs:line 86

Soon as I take out dependencies then the IpRateLimiting is fine.

How do I use to serve both serilog and previous config sections?

nblumhardt commented 6 years ago

Thanks for the note; would it be possible to include your target framework and <PackageReference> information from your CSPROJ file? Thanks!

mgrishkov commented 6 years ago

I've got the same issue. How did you fix it?

pberggreen commented 6 years ago

I also have this problem. Why was it closed? I am using the latest version of Serilog (2.6.0). I am using the full .Net framework.

nblumhardt commented 6 years ago

Why was it closed?

Requested more info on Oct 28. Still didn't have it by 18th Jan :-)

If you have the issue, would you mind please opening a new ticket including your package reference information, build output etc.? Thanks!