Skip to content

Commit dcacbbc

Browse files
authored
dotnet 8.0 updates (#171)
1 parent 2cfa29b commit dcacbbc

File tree

11 files changed

+84
-74
lines changed

11 files changed

+84
-74
lines changed

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
2-
COPY . /
1+
FROM microsoft/dotnet:8.0-sdk AS build
2+
ADD . /
33
WORKDIR /sample/Sample
44
RUN dotnet restore
5-
RUN dotnet publish -c Release -o out -f net6.0
5+
RUN dotnet publish -c Release -o out -f net8.0
66

7-
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS runtime
7+
FROM microsoft/dotnet:8.0-runtime AS runtime
88
WORKDIR /sample/Sample
99
COPY --from=build /sample/Sample/out ./
1010
ENTRYPOINT ["dotnet", "Sample.dll"]

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '{build}'
22
skip_tags: true
33
image:
4-
- Visual Studio 2019
4+
- Visual Studio 2022
55
- Ubuntu2004
66
configuration:
77
- Release

build.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ dotnet restore
77
for path in src/**/Serilog.Sinks.Splunk.csproj; do
88
dotnet build -f netstandard2.0 -c Release ${path}
99
dotnet build -f netstandard2.1 -c Release ${path}
10-
dotnet build -f net6.0 -c Release ${path}
1110
done
1211

1312
for path in test/*.Tests/*.csproj; do
14-
dotnet test -f net6.0 -c Release ${path}
13+
dotnet test -f net8.0 -c Release ${path}
1514
done
1615

17-
dotnet build -f net6.0 -c Release sample/Sample/Sample.csproj
16+
dotnet build -f net8.0 -c Release sample/Sample/Sample.csproj

sample/Sample/Program.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using System.Collections.Generic;
2-
using System.Linq;
3-
using System.IO;
1+
using Microsoft.Extensions.Configuration;
42
using Serilog;
53
using Serilog.Sinks.Splunk;
6-
using Microsoft.Extensions.Configuration;
74
using System;
5+
using System.Collections.Generic;
6+
using System.IO;
7+
using System.Linq;
88

99
namespace Sample
1010
{
@@ -18,7 +18,7 @@ public class Program
1818
public static void Main(string[] args)
1919
{
2020
// Bootstrap a simple logger.
21-
var logger = new LoggerConfiguration()
21+
var logger = new LoggerConfiguration()
2222
.WriteTo.Console()
2323
.CreateLogger();
2424

@@ -94,7 +94,6 @@ public static void UsingAppSettingsJson(int eventsToCreate)
9494
var configuration = new ConfigurationBuilder()
9595
.SetBasePath(Directory.GetCurrentDirectory())
9696
.AddJsonFile("appsettings.json")
97-
.AddUserSecrets<Program>()
9897
.Build();
9998

10099
Log.Logger = new LoggerConfiguration()

sample/Sample/Sample.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>
99
<PackageReference Include="Serilog" Version="3.1.1" />
1010
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
11-
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
12-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
11+
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
12+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

src/Serilog.Sinks.Splunk/Serilog.Sinks.Splunk.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Description>The Splunk Sink for Serilog</Description>
55
<VersionPrefix>4.0.0</VersionPrefix>
66
<Authors>Matthew Erbs, Serilog Contributors</Authors>
7-
<TargetFrameworks>netstandard2.1;netstandard2.0;net6.0</TargetFrameworks>
7+
<TargetFrameworks>netstandard2.1;netstandard2.0;net6.0;net8.0</TargetFrameworks>
88
<GenerateDocumentationFile>true</GenerateDocumentationFile>
99
<AssemblyName>Serilog.Sinks.Splunk</AssemblyName>
1010
<PackageId>Serilog.Sinks.Splunk</PackageId>
@@ -24,7 +24,7 @@
2424

2525
<ItemGroup>
2626
<PackageReference Include="Serilog" Version="3.1.1" />
27-
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="4.0.0" />
27+
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="4.0.1" />
2828
</ItemGroup>
2929

3030
</Project>

src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorSink.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,11 @@ public EventCollectorSink(
164164
: new EventCollectorClient(eventCollectorToken);
165165
}
166166

167-
/// <inheritdoc />
168-
public async Task EmitBatchAsync(IEnumerable<LogEvent> events)
167+
/// <summary>
168+
/// Emit a batch of log events, running asynchronously.
169+
/// </summary>
170+
/// <param name="events">The events to emit.</param>
171+
public virtual async Task EmitBatchAsync(IEnumerable<LogEvent> events)
169172
{
170173
var allEvents = new StringWriter();
171174

src/Serilog.Sinks.Splunk/SplunkLoggingConfigurationExtensions.cs

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
// limitations under the License.
1414

1515

16-
using System;
17-
using System.Net.Http;
1816
using Serilog.Configuration;
1917
using Serilog.Core;
2018
using Serilog.Events;
2119
using Serilog.Formatting;
20+
using Serilog.Formatting.Json;
2221
using Serilog.Sinks.PeriodicBatching;
2322
using Serilog.Sinks.Splunk;
23+
using System;
24+
using System.Net.Http;
2425

2526
namespace Serilog
2627
{
@@ -64,25 +65,33 @@ public static LoggerConfiguration EventCollector(
6465
int batchIntervalInSeconds = 2,
6566
int batchSizeLimit = 100,
6667
int? queueLimit = null,
67-
HttpMessageHandler messageHandler = null,
68+
HttpMessageHandler messageHandler = null,
6869
LoggingLevelSwitch levelSwitch = null)
6970
{
7071
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
7172

73+
var batchingOptions = new PeriodicBatchingSinkOptions
74+
{
75+
BatchSizeLimit = batchSizeLimit,
76+
Period = TimeSpan.FromSeconds(batchIntervalInSeconds),
77+
EagerlyEmitFirstEvent = true,
78+
QueueLimit = queueLimit
79+
};
80+
7281
var eventCollectorSink = new EventCollectorSink(
7382
splunkHost,
74-
eventCollectorToken,
83+
eventCollectorToken,
7584
uriPath,
76-
source,
77-
sourceType,
78-
host,
85+
source,
86+
sourceType,
87+
host,
7988
index,
8089
formatProvider,
8190
renderTemplate,
8291
messageHandler);
92+
var batchingSink = new PeriodicBatchingSink(eventCollectorSink, batchingOptions);
8393

84-
return configuration.BuildPeriodicBatchingSink(eventCollectorSink, restrictedToMinimumLevel, levelSwitch,
85-
batchIntervalInSeconds, batchSizeLimit, queueLimit);
94+
return configuration.Sink(batchingSink, restrictedToMinimumLevel, levelSwitch);
8695
}
8796

8897
/// <summary>
@@ -117,16 +126,25 @@ public static LoggerConfiguration EventCollector(
117126
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
118127
if (jsonFormatter == null) throw new ArgumentNullException(nameof(jsonFormatter));
119128

129+
130+
var batchingOptions = new PeriodicBatchingSinkOptions
131+
{
132+
BatchSizeLimit = batchSizeLimit,
133+
Period = TimeSpan.FromSeconds(batchIntervalInSeconds),
134+
EagerlyEmitFirstEvent = true,
135+
QueueLimit = queueLimit
136+
};
137+
120138
var eventCollectorSink = new EventCollectorSink(
121139
splunkHost,
122140
eventCollectorToken,
123141
uriPath,
124-
125142
jsonFormatter,
126143
messageHandler);
127144

128-
return configuration.BuildPeriodicBatchingSink(eventCollectorSink, restrictedToMinimumLevel, levelSwitch,
129-
batchIntervalInSeconds, batchSizeLimit, queueLimit);
145+
var batchingSink = new PeriodicBatchingSink(eventCollectorSink, batchingOptions);
146+
147+
return configuration.Sink(batchingSink, restrictedToMinimumLevel, levelSwitch);
130148
}
131149

132150

@@ -172,39 +190,30 @@ public static LoggerConfiguration EventCollector(
172190
{
173191
if (configuration == null) throw new ArgumentNullException(nameof(configuration));
174192

175-
var eventCollectorSink = new EventCollectorSink(
176-
splunkHost,
177-
eventCollectorToken,
178-
uriPath,
179-
source,
180-
sourceType,
181-
host,
182-
index,
183-
fields,
184-
formatProvider,
185-
renderTemplate,
186-
messageHandler
187-
);
188-
189-
return configuration.BuildPeriodicBatchingSink(eventCollectorSink, restrictedToMinimumLevel, levelSwitch,
190-
batchIntervalInSeconds, batchSizeLimit, queueLimit);
191-
}
192-
193-
private static LoggerConfiguration BuildPeriodicBatchingSink(this LoggerSinkConfiguration configuration,
194-
EventCollectorSink eventCollectorSink,
195-
LogEventLevel restrictedToMinimumLevel,
196-
LoggingLevelSwitch levelSwitch = null,
197-
int batchIntervalInSeconds = 2,
198-
int batchSizeLimit = 100,
199-
int? queueLimit = EventCollectorSink.DefaultQueueLimit)
200-
{
201-
var periodicBatchingOptions = new PeriodicBatchingSinkOptions
193+
var batchingOptions = new PeriodicBatchingSinkOptions
202194
{
203-
Period = TimeSpan.FromSeconds(batchIntervalInSeconds), QueueLimit = queueLimit, BatchSizeLimit = batchSizeLimit
195+
BatchSizeLimit = batchSizeLimit,
196+
Period = TimeSpan.FromSeconds(batchIntervalInSeconds),
197+
EagerlyEmitFirstEvent = true,
198+
QueueLimit = queueLimit
204199
};
205-
var periodicBatchSink = new PeriodicBatchingSink(eventCollectorSink, periodicBatchingOptions);
206200

207-
return configuration.Sink(periodicBatchSink, restrictedToMinimumLevel, levelSwitch);
201+
var eventCollectorSink = new EventCollectorSink(
202+
splunkHost,
203+
eventCollectorToken,
204+
uriPath,
205+
source,
206+
sourceType,
207+
host,
208+
index,
209+
fields,
210+
formatProvider,
211+
renderTemplate,
212+
messageHandler);
213+
214+
var batchingSink = new PeriodicBatchingSink(eventCollectorSink, batchingOptions);
215+
216+
return configuration.Sink(batchingSink, restrictedToMinimumLevel, levelSwitch);
208217
}
209218
}
210219
}

src/Serilog.Sinks.TCP/Serilog.Sinks.Splunk.TCP.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</PropertyGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="Serilog.Sinks.Splunk" Version="3.6.0" />
23+
<PackageReference Include="Serilog.Sinks.Splunk" Version="3.7.0" />
2424
<PackageReference Include="Splunk.Logging.Common.Core" Version="1.0.0" />
2525
</ItemGroup>
2626
</Project>

src/Serilog.Sinks.UDP/Serilog.Sinks.Splunk.UDP.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
</PropertyGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="Serilog.Sinks.Splunk" Version="3.6.0" />
23+
<PackageReference Include="Serilog.Sinks.Splunk" Version="3.7.0" />
2424
</ItemGroup>
2525
</Project>

0 commit comments

Comments
 (0)