datalust/serilog-sinks-seq

Incompatibility between Serilog.Sinks.Seq 7.0.0 and Serilog.Sinks.Dynatrace 1.0.7

SmartymindPersonal opened this issue · 3 comments

I get the following error when I updated Serilog.Sinks.Seq from 6.0.0 to 7.0.0:

System.TypeLoadException
HResult=0x80131522
Message=Could not load type 'Serilog.Sinks.Http.Private.Sinks.HttpSink' from assembly 'Serilog.Sinks.Http, Version=5.1.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10' because the parent type is sealed.
Source=System.Private.CoreLib

We are using Serilog from configuration in Program.cs:
builder.Host.UseSerilog((context, _, configuration) => configuration.ReadFrom.Configuration(context.Configuration))

We are using DryIoc as you can see in the stack trace below but I think it is not relevant. It works with Serilog.Sinks.Seq 6.0.0.

Stacktrace:

at System.Reflection.RuntimeAssembly.GetExportedTypes() in //src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs:line 264
at Serilog.Settings.Configuration.ConfigurationReader.<>c__DisplayClass34_0.b__1(Assembly a) in Serilog.Settings.Configuration\ConfigurationReader.cs:line 522
at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext() in /_/src/libraries/System.Linq/src/System/Linq/SelectMany.cs:line 184 at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext() in /
/src/libraries/System.Linq/src/System/Linq/SelectMany.cs:line 176
at System.Linq.Enumerable.WhereEnumerableIterator1.ToList() in /_/src/libraries/System.Linq/src/System/Linq/Where.SpeedOpt.cs:line 54 at Serilog.Settings.Configuration.ConfigurationReader.FindConfigurationExtensionMethods(IReadOnlyCollection1 configurationAssemblies, Type configType, Boolean allowInternalTypes, Boolean allowInternalMethods) in Serilog.Settings.Configuration\ConfigurationReader.cs:line 517
at Serilog.Settings.Configuration.ConfigurationReader.FindEventEnricherConfigurationMethods(IReadOnlyCollection1 configurationAssemblies, Boolean allowInternalTypes, Boolean allowInternalMethods) in Serilog.Settings.Configuration\ConfigurationReader.cs:line 506 at Serilog.Settings.Configuration.ConfigurationReader.ApplyEnrichment(LoggerConfiguration loggerConfiguration) in Serilog.Settings.Configuration\ConfigurationReader.cs:line 271 at Serilog.Settings.Configuration.ConfigurationReader.Configure(LoggerConfiguration loggerConfiguration) in Serilog.Settings.Configuration\ConfigurationReader.cs:line 52 at Serilog.Configuration.LoggerSettingsConfiguration.Settings(ILoggerSettings settings) in Serilog.Configuration\LoggerSettingsConfiguration.cs:line 19 at Serilog.ConfigurationLoggerConfigurationExtensions.Configuration(LoggerSettingsConfiguration settingConfiguration, IConfiguration configuration, ConfigurationReaderOptions readerOptions) in Serilog\ConfigurationLoggerConfigurationExtensions.cs:line 161 at Program.<>c.<<Main>$>b__0_0(HostBuilderContext context, IServiceProvider _, LoggerConfiguration configuration) in C:\...\Program.cs:line 44 at Serilog.SerilogHostBuilderExtensions.<>c__DisplayClass2_1.<UseSerilog>b__1(IServiceProvider services, LoggerConfiguration loggerConfiguration) at Serilog.SerilogServiceCollectionExtensions.<>c__DisplayClass3_1.<AddSerilog>b__3(LoggerConfiguration cfg) at Serilog.Extensions.Hosting.ReloadableLogger.Reload(Func2 configure)
at Serilog.SerilogServiceCollectionExtensions.<>c__DisplayClass3_0.b__0(IServiceProvider services)
at DryIoc.Interpreter.TryInterpret(IResolverContext r, Expression expr, IParameterProvider paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Object& result) in //src/DryIoc/Container.cs:line 3588
at DryIoc.Interpreter.InterpretOrCompileSingletonAndUnwrapContainerException(IResolverContext r, Expression expr, ImHashMapEntry2 itemRef) in /_/src/DryIoc/Container.cs:line 3313 at DryIoc.Factory.GetExpressionOrDefault(Request request) in /_/src/DryIoc/Container.cs:line 11828 at DryIoc.Container.ResolveAndCache(Int32 serviceTypeHash, Type serviceType, IfUnresolved ifUnresolved) in /_/src/DryIoc/Container.cs:line 400 at DryIoc.Container.Resolve(Type serviceType, IfUnresolved ifUnresolved) in /_/src/DryIoc/Container.cs:line 369 at DryIoc.Container.System.IServiceProvider.GetService(Type serviceType) in /_/src/DryIoc/Container.cs:line 317 at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType) in /_/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ServiceProviderServiceExtensions.cs:line 45 at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) in /_/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ServiceProviderServiceExtensions.cs:line 65 at Serilog.SerilogServiceCollectionExtensions.<>c__DisplayClass3_0.<AddSerilog>b__2(IServiceProvider services) at DryIoc.Interpreter.TryInterpret(IResolverContext r, Expression expr, IParameterProvider paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Object& result) in /_/src/DryIoc/Container.cs:line 3588 at DryIoc.Interpreter.InterpretOrCompileSingletonAndUnwrapContainerException(IResolverContext r, Expression expr, ImHashMapEntry2 itemRef) in /
/src/DryIoc/Container.cs:line 3313
at DryIoc.Factory.GetExpressionOrDefault(Request request) in //src/DryIoc/Container.cs:line 11828
at DryIoc.ReflectionFactory.CreateExpressionOrDefault(Request request) in /
/src/DryIoc/Container.cs:line 12925
at DryIoc.Factory.GetExpressionOrDefault(Request request) in //src/DryIoc/Container.cs:line 11777
at DryIoc.ReflectionFactory.CreateExpressionOrDefault(Request request) in /
/src/DryIoc/Container.cs:line 12925
at DryIoc.Factory.GetExpressionOrDefault(Request request) in //src/DryIoc/Container.cs:line 11777
at DryIoc.Container.ResolveAndCache(Int32 serviceTypeHash, Type serviceType, IfUnresolved ifUnresolved) in /
/src/DryIoc/Container.cs:line 400
at DryIoc.Container.Resolve(Type serviceType, IfUnresolved ifUnresolved) in //src/DryIoc/Container.cs:line 369
at DryIoc.Microsoft.DependencyInjection.DryIocServiceProvider.GetRequiredService(Type serviceType) in /
/src/DryIoc.Microsoft.DependencyInjection/DryIocAdapter.cs:line 494
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) in //src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ServiceProviderServiceExtensions.cs:line 65
at Microsoft.Extensions.Hosting.HostBuilder.<>c__DisplayClass35_0.b__2(IServiceProvider ) in //src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.cs:line 321
at DryIoc.Interpreter.TryInterpret(IResolverContext r, Expression expr, IParameterProvider paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Object& result) in /
/src/DryIoc/Container.cs:line 3588
at DryIoc.Interpreter.InterpretOrCompileSingletonAndUnwrapContainerException(IResolverContext r, Expression expr, ImHashMapEntry`2 itemRef) in //src/DryIoc/Container.cs:line 3313
at DryIoc.Factory.GetExpressionOrDefault(Request request) in /
/src/DryIoc/Container.cs:line 11828
at DryIoc.Container.ResolveAndCache(Int32 serviceTypeHash, Type serviceType, IfUnresolved ifUnresolved) in //src/DryIoc/Container.cs:line 400
at DryIoc.Container.Resolve(Type serviceType, IfUnresolved ifUnresolved) in /
/src/DryIoc/Container.cs:line 369
at DryIoc.Microsoft.DependencyInjection.DryIocServiceProvider.GetRequiredService(Type serviceType) in //src/DryIoc.Microsoft.DependencyInjection/DryIocAdapter.cs:line 494
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) in /
/src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ServiceProviderServiceExtensions.cs:line 65
at Microsoft.Extensions.Hosting.HostBuilder.ResolveHost(IServiceProvider serviceProvider, DiagnosticListener diagnosticListener) in //src/libraries/Microsoft.Extensions.Hosting/src/HostBuilder.cs:line 373
at Microsoft.Extensions.Hosting.HostApplicationBuilder.Build() in /
/src/libraries/Microsoft.Extensions.Hosting/src/HostApplicationBuilder.cs:line 248
at Microsoft.AspNetCore.Builder.WebApplicationBuilder.Build() in /_/src/DefaultBuilder/src/WebApplicationBuilder.cs:line 382
at Program.<

$>d__0.MoveNext() in C:...\Program.cs:line 50
at Program.<$>d__0.MoveNext() in C:...\Program.cs:line 71
at Program.(String[] args)

Hi! The Dynatrace sink has a dependency on Serilog.Sinks.Http v5.1.0, which is about 5 years old and uses a now-obsolete Serilog.Sinks.PeriodicBatching implementation.

If you add <PackageReference Include="Serilog.Sinks.Http" Version="8.0.0" /> to your CSPROJ, this should be resolved, unless the Dynatrace sink depends on APIs in the HTTP sink that are now removed or broken. I can help send an update PR to the Dynatrace sink if so.

Keen to hear how you go!

Thanks for the update PR. I've just did a quick review of it.

Version 7.0.1 of this package also addresses the incompatibility. Thanks again!