Skip to content

Commit 70c3787

Browse files
authored
Merge pull request #326 from serilog/dev
Release 5.6.0
2 parents fa57d29 + e05b610 commit 70c3787

File tree

63 files changed

+1257
-535
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1257
-535
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 5.6.0
2+
* Fixed issue #191: Added option `EagerlyEmitFirstEvent` by implementing new PeriodicBatchingSink API.
3+
* Replaced `SinkOptions` with `MSSqlServerSinkOptions` and cleaned up namespaced (thanks to @jonorossi for the contribution).
4+
* Target .NET Core 2.1 (LTS) instead of 2.2
5+
* Fixed issue #312: Data conversion issue causes logging to silently fail.
6+
17
# 5.5.1
28
* Fixed issue #300 Support DateTime2 data type for TimeStamp column (thanks to @stedel for the contribution).
39
* Added Sourcelink support and publish symbols to nuget.org which allows consumers of the package to debug into the sink code.

README.md

Lines changed: 27 additions & 22 deletions
Large diffs are not rendered by default.

appveyor.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ configuration: Release
55
install:
66
- ps: mkdir -Force ".\build\" | Out-Null
77
build_script:
8-
- ps: ./Build.ps1
8+
- ps: ./Build.ps1
99
test: off
1010
artifacts:
11-
- path: artifacts/Serilog.*.nupkg
12-
- path: artifacts/Serilog.*.snupkg
11+
- path: artifacts/Serilog.*.nupkg
12+
- path: artifacts/Serilog.*.snupkg
1313
deploy:
14-
- provider: NuGet
15-
api_key:
16-
secure: K3/810hkTO6rd2AEHVkUQAadjGmDREus9k96QHu6hxrA1/wRTuAJemHMKtVVgIvf
17-
on:
18-
branch: /^(master|dev)$/
19-
- provider: GitHub
20-
auth_token:
21-
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
22-
artifacts:
23-
/Serilog.*\.nupkg/
24-
/Serilog.*\.snupkg/
25-
tag: v$(appveyor_build_version)
26-
on:
27-
branch: master
14+
- provider: NuGet
15+
api_key:
16+
secure: K3/810hkTO6rd2AEHVkUQAadjGmDREus9k96QHu6hxrA1/wRTuAJemHMKtVVgIvf
17+
on:
18+
branch: /^(master|dev)$/
19+
- provider: GitHub
20+
auth_token:
21+
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
22+
artifacts:
23+
/Serilog.*\.nupkg/
24+
/Serilog.*\.snupkg/
25+
tag: v$(appveyor_build_version)
26+
on:
27+
branch: master

sample/AppConfigDemo/App.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
<BatchPostingLimit Value="13" />
1212
<BatchPeriod Value="00:00:15" />
13+
<EagerlyEmitFirstEvent Value="true" />
1314

1415
<AddStandardColumns>
1516
<add Name="LogEvent" />

sample/AppConfigDemo/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Threading;
33
using Serilog;
44
using Serilog.Events;
5-
using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options;
5+
using Serilog.Sinks.MSSqlServer;
66

77
namespace AppConfigDemo
88
{
@@ -29,11 +29,11 @@ public static void Main()
2929
// logEventFormatter: null)
3030
// .CreateLogger();
3131

32-
// New SinkOptions based interface
32+
// New MSSqlServerSinkOptions based interface
3333
Log.Logger = new LoggerConfiguration().WriteTo
3434
.MSSqlServer(
3535
connectionString: _connectionString,
36-
sinkOptions: new SinkOptions
36+
sinkOptions: new MSSqlServerSinkOptions
3737
{
3838
TableName = _tableName,
3939
SchemaName = _schemaName,

sample/CombinedConfigDemo/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Threading;
33
using Microsoft.Extensions.Configuration;
44
using Serilog;
5-
using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options;
5+
using Serilog.Sinks.MSSqlServer;
66

77
namespace CombinedConfigDemo
88
{
@@ -38,7 +38,7 @@ public static void Main()
3838
Log.Logger = new LoggerConfiguration()
3939
.WriteTo.MSSqlServer(
4040
connectionString: _connectionStringName,
41-
sinkOptions: new SinkOptions
41+
sinkOptions: new MSSqlServerSinkOptions
4242
{
4343
TableName = _tableName,
4444
SchemaName = _schemaName,

sample/CombinedConfigDemo/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"Serilog": {
1313
"SinkOptions": {
1414
"batchPostingLimit": 5,
15-
"batchPeriod": "00:00:15"
15+
"batchPeriod": "00:00:15",
16+
"eagerlyEmitFirstEvent": true
1617
},
1718
"ColumnOptions": {
1819
"addStandardColumns": [ "LogEvent" ],

sample/CustomLogEventFormatterDemo/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Threading;
33
using Serilog;
44
using Serilog.Sinks.MSSqlServer;
5-
using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options;
65

76
namespace CustomLogEventFormatterDemo
87
{
@@ -34,10 +33,10 @@ public static void Main()
3433
// logEventFormatter: customFormatter)
3534
// .CreateLogger();
3635

37-
// New SinkOptions based interface
36+
// New MSSqlServerSinkOptions based interface
3837
Log.Logger = new LoggerConfiguration()
3938
.WriteTo.MSSqlServer(_connectionString,
40-
sinkOptions: new SinkOptions
39+
sinkOptions: new MSSqlServerSinkOptions
4140
{
4241
TableName = _tableName,
4342
SchemaName = _schemaName,

sample/NetStandardDemo/NetStandardDemoLib/Initializer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Serilog;
44
using Serilog.Events;
55
using Serilog.Sinks.MSSqlServer;
6-
using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options;
76

87
namespace NetStandardDemoLib
98
{
@@ -18,7 +17,7 @@ public static LoggerConfiguration CreateLoggerConfiguration()
1817
.Enrich.FromLogContext()
1918
.WriteTo.MSSqlServer(
2019
_connectionString,
21-
new SinkOptions
20+
new MSSqlServerSinkOptions
2221
{
2322
TableName = _tableName,
2423
AutoCreateSqlTable = true

src/Serilog.Sinks.MSSqlServer/Configuration/Extensions/Hybrid/LoggerConfigurationMSSqlServerExtensions.cs

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
using Serilog.Formatting;
2121
using Serilog.Sinks.MSSqlServer;
2222
using Serilog.Sinks.MSSqlServer.Configuration.Factories;
23-
using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options;
2423

2524
// The "Hybrid" configuration system supports both Microsoft.Extensions.Configuration and System.Configuration.
2625
// This is necessary because .NET Framework 4.6.1+ and .NET Core 2.0+ apps support both approaches, whereas the
@@ -44,7 +43,7 @@ public static class LoggerConfigurationMSSqlServerExtensions
4443
/// https://gist.github.com/mivano/10429656
4544
/// or use the autoCreateSqlTable option.
4645
///
47-
/// Note: this is the legacy version of the extension method. Please use the new one using SinkOptions instead.
46+
/// Note: this is the legacy version of the extension method. Please use the new one using MSSqlServerSinkOptions instead.
4847
///
4948
/// </summary>
5049
/// <param name="loggerConfiguration">The logger configuration.</param>
@@ -62,7 +61,7 @@ public static class LoggerConfigurationMSSqlServerExtensions
6261
/// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
6362
/// <returns>Logger configuration, allowing configuration to continue.</returns>
6463
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
65-
[Obsolete("Use the new interface accepting a SinkOptions parameter instead. This will be removed in a future release.", error: false)]
64+
[Obsolete("Use the new interface accepting a MSSqlServerSinkOptions parameter instead. This will be removed in a future release.", error: false)]
6665
public static LoggerConfiguration MSSqlServer(
6766
this LoggerSinkConfiguration loggerConfiguration,
6867
string connectionString,
@@ -79,9 +78,9 @@ public static LoggerConfiguration MSSqlServer(
7978
ITextFormatter logEventFormatter = null)
8079
{
8180
// Do not add new parameters here. This interface is considered legacy and will be deprecated in the future.
82-
// For adding new input parameters use the SinkOptions class and the method overload that accepts SinkOptions.
81+
// For adding new input parameters use the MSSqlServerSinkOptions class and the method overload that accepts MSSqlServerSinkOptions.
8382

84-
var sinkOptions = new SinkOptions(tableName, batchPostingLimit, period, autoCreateSqlTable, schemaName);
83+
var sinkOptions = new MSSqlServerSinkOptions(tableName, batchPostingLimit, period, autoCreateSqlTable, schemaName);
8584

8685
return loggerConfiguration.MSSqlServer(
8786
connectionString: connectionString,
@@ -116,7 +115,7 @@ public static LoggerConfiguration MSSqlServer(
116115
public static LoggerConfiguration MSSqlServer(
117116
this LoggerSinkConfiguration loggerConfiguration,
118117
string connectionString,
119-
SinkOptions sinkOptions = null,
118+
MSSqlServerSinkOptions sinkOptions = null,
120119
IConfigurationSection sinkOptionsSection = null,
121120
IConfiguration appConfiguration = null,
122121
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
@@ -136,23 +135,25 @@ public static LoggerConfiguration MSSqlServer(
136135
logEventFormatter: logEventFormatter,
137136
applySystemConfiguration: new ApplySystemConfiguration(),
138137
applyMicrosoftExtensionsConfiguration: new ApplyMicrosoftExtensionsConfiguration(),
139-
sinkFactory: new MSSqlServerSinkFactory());
138+
sinkFactory: new MSSqlServerSinkFactory(),
139+
batchingSinkFactory: new PeriodicBatchingSinkFactory());
140140

141141
// Internal overload with parameters used by tests to override the config section and inject mocks
142142
internal static LoggerConfiguration MSSqlServerInternal(
143143
this LoggerSinkConfiguration loggerConfiguration,
144144
string connectionString,
145-
SinkOptions sinkOptions = null,
146-
IConfigurationSection sinkOptionsSection = null,
147-
IConfiguration appConfiguration = null,
148-
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
149-
IFormatProvider formatProvider = null,
150-
ColumnOptions columnOptions = null,
151-
IConfigurationSection columnOptionsSection = null,
152-
ITextFormatter logEventFormatter = null,
153-
IApplySystemConfiguration applySystemConfiguration = null,
154-
IApplyMicrosoftExtensionsConfiguration applyMicrosoftExtensionsConfiguration = null,
155-
IMSSqlServerSinkFactory sinkFactory = null)
145+
MSSqlServerSinkOptions sinkOptions,
146+
IConfigurationSection sinkOptionsSection,
147+
IConfiguration appConfiguration,
148+
LogEventLevel restrictedToMinimumLevel,
149+
IFormatProvider formatProvider,
150+
ColumnOptions columnOptions,
151+
IConfigurationSection columnOptionsSection,
152+
ITextFormatter logEventFormatter,
153+
IApplySystemConfiguration applySystemConfiguration,
154+
IApplyMicrosoftExtensionsConfiguration applyMicrosoftExtensionsConfiguration,
155+
IMSSqlServerSinkFactory sinkFactory,
156+
IPeriodicBatchingSinkFactory batchingSinkFactory)
156157
{
157158
if (loggerConfiguration == null)
158159
throw new ArgumentNullException(nameof(loggerConfiguration));
@@ -162,13 +163,15 @@ internal static LoggerConfiguration MSSqlServerInternal(
162163

163164
var sink = sinkFactory.Create(connectionString, sinkOptions, formatProvider, columnOptions, logEventFormatter);
164165

165-
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
166+
var periodicBatchingSink = batchingSinkFactory.Create(sink, sinkOptions);
167+
168+
return loggerConfiguration.Sink(periodicBatchingSink, restrictedToMinimumLevel);
166169
}
167170

168171
/// <summary>
169172
/// Adds a sink that writes log events to a table in a MSSqlServer database.
170173
///
171-
/// Note: this is the legacy version of the extension method. Please use the new one using SinkOptions instead.
174+
/// Note: this is the legacy version of the extension method. Please use the new one using MSSqlServerSinkOptions instead.
172175
///
173176
/// </summary>
174177
/// <param name="loggerAuditSinkConfiguration">The logger configuration.</param>
@@ -184,7 +187,7 @@ internal static LoggerConfiguration MSSqlServerInternal(
184187
/// <param name="logEventFormatter">Supplies custom formatter for the LogEvent column, or null</param>
185188
/// <returns>Logger configuration, allowing configuration to continue.</returns>
186189
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
187-
[Obsolete("Use the new interface accepting a SinkOptions parameter instead. This will be removed in a future release.", error: false)]
190+
[Obsolete("Use the new interface accepting a MSSqlServerSinkOptions parameter instead. This will be removed in a future release.", error: false)]
188191
public static LoggerConfiguration MSSqlServer(
189192
this LoggerAuditSinkConfiguration loggerAuditSinkConfiguration,
190193
string connectionString,
@@ -199,9 +202,9 @@ public static LoggerConfiguration MSSqlServer(
199202
ITextFormatter logEventFormatter = null)
200203
{
201204
// Do not add new parameters here. This interface is considered legacy and will be deprecated in the future.
202-
// For adding new input parameters use the SinkOptions class and the method overload that accepts SinkOptions.
205+
// For adding new input parameters use the MSSqlServerSinkOptions class and the method overload that accepts MSSqlServerSinkOptions.
203206

204-
var sinkOptions = new SinkOptions(tableName, null, null, autoCreateSqlTable, schemaName);
207+
var sinkOptions = new MSSqlServerSinkOptions(tableName, null, null, autoCreateSqlTable, schemaName);
205208

206209
return loggerAuditSinkConfiguration.MSSqlServer(
207210
connectionString: connectionString,
@@ -233,7 +236,7 @@ public static LoggerConfiguration MSSqlServer(
233236
public static LoggerConfiguration MSSqlServer(
234237
this LoggerAuditSinkConfiguration loggerAuditSinkConfiguration,
235238
string connectionString,
236-
SinkOptions sinkOptions = null,
239+
MSSqlServerSinkOptions sinkOptions = null,
237240
IConfigurationSection sinkOptionsSection = null,
238241
IConfiguration appConfiguration = null,
239242
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
@@ -259,17 +262,17 @@ public static LoggerConfiguration MSSqlServer(
259262
internal static LoggerConfiguration MSSqlServerInternal(
260263
this LoggerAuditSinkConfiguration loggerAuditSinkConfiguration,
261264
string connectionString,
262-
SinkOptions sinkOptions = null,
263-
IConfigurationSection sinkOptionsSection = null,
264-
IConfiguration appConfiguration = null,
265-
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
266-
IFormatProvider formatProvider = null,
267-
ColumnOptions columnOptions = null,
268-
IConfigurationSection columnOptionsSection = null,
269-
ITextFormatter logEventFormatter = null,
270-
IApplySystemConfiguration applySystemConfiguration = null,
271-
IApplyMicrosoftExtensionsConfiguration applyMicrosoftExtensionsConfiguration = null,
272-
IMSSqlServerAuditSinkFactory auditSinkFactory = null)
265+
MSSqlServerSinkOptions sinkOptions,
266+
IConfigurationSection sinkOptionsSection,
267+
IConfiguration appConfiguration,
268+
LogEventLevel restrictedToMinimumLevel,
269+
IFormatProvider formatProvider,
270+
ColumnOptions columnOptions,
271+
IConfigurationSection columnOptionsSection,
272+
ITextFormatter logEventFormatter,
273+
IApplySystemConfiguration applySystemConfiguration,
274+
IApplyMicrosoftExtensionsConfiguration applyMicrosoftExtensionsConfiguration,
275+
IMSSqlServerAuditSinkFactory auditSinkFactory)
273276
{
274277
if (loggerAuditSinkConfiguration == null)
275278
throw new ArgumentNullException(nameof(loggerAuditSinkConfiguration));
@@ -284,15 +287,15 @@ internal static LoggerConfiguration MSSqlServerInternal(
284287

285288
private static void ReadConfiguration(
286289
ref string connectionString,
287-
ref SinkOptions sinkOptions,
290+
ref MSSqlServerSinkOptions sinkOptions,
288291
IConfigurationSection sinkOptionsSection,
289292
IConfiguration appConfiguration,
290293
ref ColumnOptions columnOptions,
291294
IConfigurationSection columnOptionsSection,
292295
IApplySystemConfiguration applySystemConfiguration,
293296
IApplyMicrosoftExtensionsConfiguration applyMicrosoftExtensionsConfiguration)
294297
{
295-
sinkOptions = sinkOptions ?? new SinkOptions();
298+
sinkOptions = sinkOptions ?? new MSSqlServerSinkOptions();
296299
columnOptions = columnOptions ?? new ColumnOptions();
297300

298301
var serviceConfigSection = applySystemConfiguration.GetSinkConfigurationSection(AppConfigSectionName);

0 commit comments

Comments
 (0)