Skip to content

Commit

Permalink
Merge pull request #557 from ckadluba/serilog4-update
Browse files Browse the repository at this point in the history
Update serilog to 4 and move batching to Serilog core (fixed tests)
  • Loading branch information
ckadluba authored Sep 4, 2024
2 parents aecd61e + 7305ce3 commit ea15c53
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 136 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 7.0.0
* Fixed issue #543: Update to Serilog v4, remove reference to Serilog.Sinks.PeriodicBatching (thanks to @cancakar35)

# 6.7.1
* Fixed issue #552 by downgrading SqlClient dependency to 5.1.6 which is LTS and fixed the vulnerabilities referenced in issue #544
* Fixed vulnerabilities by removing all System.* 4 versions as recommended by Microsoft (https://devblogs.microsoft.com/nuget/nugetaudit-2-0-elevating-security-and-trust-in-package-management/#system-net-http-and-system-text-regularexpressions, issue #544)
Expand Down
3 changes: 1 addition & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
<PackageVersion Include="Moq" Version="4.18.2" />
<PackageVersion Include="xunit" Version="2.9.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="Serilog" Version="3.1.1" />
<PackageVersion Include="Serilog" Version="4.0.0" />
<PackageVersion Include="Serilog.Extensions.Hosting" Version="5.0.1" />
<PackageVersion Include="Serilog.Settings.Configuration" Version="3.4.0" />
<PackageVersion Include="Serilog.Sinks.PeriodicBatching" Version="3.1.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using System;
using Microsoft.Extensions.Configuration;
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Sinks.MSSqlServer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Serilog.Formatting;
using Serilog.Sinks.PeriodicBatching;
using Serilog.Core;

namespace Serilog.Sinks.MSSqlServer.Configuration.Factories
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Serilog.Core;
using Serilog.Sinks.PeriodicBatching;

namespace Serilog.Sinks.MSSqlServer.Configuration.Factories
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Serilog.Formatting;
using Serilog.Sinks.PeriodicBatching;
using Serilog.Core;

namespace Serilog.Sinks.MSSqlServer.Configuration.Factories
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
using Serilog.Core;
using Serilog.Sinks.PeriodicBatching;
using Serilog.Configuration;
using Serilog.Core;

namespace Serilog.Sinks.MSSqlServer.Configuration.Factories
{
internal class PeriodicBatchingSinkFactory : IPeriodicBatchingSinkFactory
{
public ILogEventSink Create(IBatchedLogEventSink sink, MSSqlServerSinkOptions sinkOptions)
{
var periodicBatchingSinkOptions = new PeriodicBatchingSinkOptions
var periodicBatchingSinkOptions = new BatchingOptions
{
BatchSizeLimit = sinkOptions.BatchPostingLimit,
Period = sinkOptions.BatchPeriod,
BufferingTimeLimit = sinkOptions.BatchPeriod,
EagerlyEmitFirstEvent = sinkOptions.EagerlyEmitFirstEvent
};

return new PeriodicBatchingSink(sink, periodicBatchingSinkOptions);
return LoggerSinkConfiguration.CreateSink(lc => lc.Sink(sink, periodicBatchingSinkOptions));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>A Serilog sink that writes events to Microsoft SQL Server and Azure SQL</Description>
<VersionPrefix>6.7.2</VersionPrefix>
<VersionPrefix>7.0.0</VersionPrefix>
<Authors>Michiel van Oudheusden;Christian Kadluba;Serilog Contributors</Authors>
<TargetFrameworks>netstandard2.0;net462;net472;net6.0</TargetFrameworks>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand Down Expand Up @@ -37,7 +37,6 @@
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
<PackageReference Include="Serilog" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" />
<PackageReference Include="System.Formats.Asn1" />
<PackageReference Include="System.Private.Uri" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
using Serilog.Formatting;
using Serilog.Sinks.MSSqlServer.Dependencies;
using Serilog.Sinks.MSSqlServer.Platform;
using Serilog.Sinks.PeriodicBatching;
using Serilog.Core;

namespace Serilog.Sinks.MSSqlServer
{
Expand Down Expand Up @@ -117,12 +117,9 @@ internal MSSqlServerSink(
/// <summary>
/// Emit a batch of log events, running asynchronously.
/// </summary>
/// <param name="events">The events to emit.</param>
/// <remarks>
/// Override either <see cref="PeriodicBatchingSink.EmitBatch" /> or <see cref="PeriodicBatchingSink.EmitBatchAsync" />, not both.
/// </remarks>
public Task EmitBatchAsync(IEnumerable<LogEvent> events) =>
_sqlBulkBatchWriter.WriteBatch(events, _eventTable);
/// <param name="batch">The events to emit.</param>
public Task EmitBatchAsync(IReadOnlyCollection<LogEvent> batch) =>
_sqlBulkBatchWriter.WriteBatch(batch, _eventTable);

/// <summary>
/// Called upon batchperiod if no data is in batch. Not used by this sink.
Expand Down
Loading

0 comments on commit ea15c53

Please sign in to comment.