datalust / serilog-sinks-seq

A Serilog sink that writes events to the Seq structured log server
https://datalust.co/seq
Apache License 2.0
225 stars 50 forks source link

Upgrading from 5.1.1 to 5.2.0 breaks API project #185

Closed alastor09 closed 1 year ago

alastor09 commented 1 year ago

When updating from 5.1.1 to 5.2.0 i started getting this exception.

Autofac.Core.DependencyResolutionException: An exception was thrown while activating ?:Microsoft.Extensions.Hosting.IHost -> Microsoft.Extensions.Hosting.Internal.ApplicationLifetime -> Microsoft.Extensions.Logging.Logger`1[[Microsoft.Extensions.Hosting.Internal.ApplicationLifetime, Microsoft.Extensions.Hosting, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]] -> ?:Microsoft.Extensions.Logging.ILoggerFactory -> ?:Serilog.SerilogHostBuilderExtensions+RegisteredLogger.
---> System.TypeLoadException: Could not load type 'Serilog.Sinks.Http.Private.Sinks.HttpSink' from assembly 'Serilog.Sinks.Http, Version=5.2.1.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10' because the parent type is sealed.
nblumhardt commented 1 year ago

Thanks for the note @alastor09.

Adding a dependency on Serilog.Sinks.PeriodicBatching v3.1.0 will resolve this, until #186 is merged (which we'll do shortly).

JochemE commented 1 year ago

I run into the same issue just with another Sink (AwsCloudWatch), explicitly adding Serilog.Sinks.PeriodicBatching resolves it indeed.

This was the call stack that i got when i created the logger:

Could not load type 'Serilog.Sinks.AwsCloudWatch.CloudWatchLogSink' from assembly 'Serilog.Sinks.AwsCloudWatch, Version=4.0.171.0, Culture=neutral, PublicKeyToken=23b095b16108dcf5' because the parent type is sealed.
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at System.Reflection.Assembly.get_ExportedTypes()
   at Serilog.Settings.Configuration.ConfigurationReader.<>c.<FindConfigurationExtensionMethods>b__32_1(Assembly a)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.ToList()
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Serilog.Settings.Configuration.ConfigurationReader.FindConfigurationExtensionMethods(IReadOnlyCollection`1 configurationAssemblies, Type configType)
   at Serilog.Settings.Configuration.ConfigurationReader.FindSinkConfigurationMethods(IReadOnlyCollection`1 configurationAssemblies)
   at Serilog.Settings.Configuration.ConfigurationReader.ApplySinks(LoggerConfiguration loggerConfiguration)
   at Serilog.Settings.Configuration.ConfigurationReader.Configure(LoggerConfiguration loggerConfiguration)
   at Serilog.Configuration.LoggerSettingsConfiguration.Settings(ILoggerSettings settings)
   at Serilog.ConfigurationLoggerConfigurationExtensions.Configuration(LoggerSettingsConfiguration settingConfiguration, IConfiguration configuration, String sectionName, DependencyContext dependencyContext)
nblumhardt commented 1 year ago

Thanks @JochemE .

v5.2.1 is out now, and fixes this: https://github.com/datalust/serilog-sinks-seq/releases/tag/v5.2.1

🎉

nblumhardt commented 1 year ago

It looks like NuGet.org is taking longer than usual to index the package - hopefully it pops up soon, I'll keep an eye on it.

JochemE commented 1 year ago

I see it on nuget and our CI build is green 💚