Skip to content

Commit 5dabed5

Browse files
authored
Merge pull request #276 from serilog/dev
Release 5.4.0
2 parents 1dd9048 + c82e860 commit 5dabed5

File tree

101 files changed

+4579
-1487
lines changed

Some content is hidden

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

101 files changed

+4579
-1487
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 5.4.0
2+
* Added support for Azure Managed Identities for Resources authentication (thanks to @darrenschwarz for the contribution).
3+
* New interface using `SinkOptions` parameter. Marked old interfaces obsolete.
4+
* Implemented Enhancement #182: configurable property names for custom columns (thanks to @rocknet for the contribution).
5+
* Lots of refactoring and new unit tests.
6+
17
# 5.3.0
28
Code quality release.
39
* Added code analysis and editorconfig rules based on Microsoft standards.

README.md

Lines changed: 131 additions & 49 deletions
Large diffs are not rendered by default.

appveyor.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ artifacts:
1212
deploy:
1313
- provider: NuGet
1414
api_key:
15-
secure: N59tiJECUYpip6tEn0xvdmDAEiP9SIzyLEFLpwiigm/8WhJvBNs13QxzT1/3/JW/
16-
skip_symbols: true
15+
secure: K3/810hkTO6rd2AEHVkUQAadjGmDREus9k96QHu6hxrA1/wRTuAJemHMKtVVgIvf
1716
on:
1817
branch: /^(master|dev)$/
1918
- provider: GitHub

sample/AppConfigDemo/App.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@
77
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
88
</startup>
99
<MSSqlServerSettingsSection>
10+
11+
<BatchPostingLimit Value="13" />
12+
<BatchPeriod Value="00:00:15" />
13+
1014
<AddStandardColumns>
1115
<add Name="LogEvent" />
1216
</AddStandardColumns>
1317
<RemoveStandardColumns>
1418
<remove Name="Properties" />
1519
</RemoveStandardColumns>
1620
<TimeStamp ColumnName="TimeStampAlternative" ConvertToUtc="true" />
21+
1722
</MSSqlServerSettingsSection>
1823
<runtime>
1924
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

sample/AppConfigDemo/Program.cs

Lines changed: 23 additions & 6 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;
5+
using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options;
66

77
namespace AppConfigDemo
88
{
@@ -14,17 +14,34 @@ public static class Program
1414

1515
public static void Main()
1616
{
17+
// Legacy interace - do not use this anymore
18+
//Log.Logger = new LoggerConfiguration().WriteTo
19+
// .MSSqlServer(
20+
// connectionString: _connectionString,
21+
// tableName: _tableName,
22+
// restrictedToMinimumLevel: LogEventLevel.Debug,
23+
// batchPostingLimit: MSSqlServerSink.DefaultBatchPostingLimit,
24+
// period: null,
25+
// formatProvider: null,
26+
// autoCreateSqlTable: true,
27+
// columnOptions: null,
28+
// schemaName: _schemaName,
29+
// logEventFormatter: null)
30+
// .CreateLogger();
31+
32+
// New SinkOptions based interface
1733
Log.Logger = new LoggerConfiguration().WriteTo
1834
.MSSqlServer(
1935
connectionString: _connectionString,
20-
tableName: _tableName,
36+
sinkOptions: new SinkOptions
37+
{
38+
TableName = _tableName,
39+
SchemaName = _schemaName,
40+
AutoCreateSqlTable = true
41+
},
2142
restrictedToMinimumLevel: LogEventLevel.Debug,
22-
batchPostingLimit: MSSqlServerSink.DefaultBatchPostingLimit,
23-
period: null,
2443
formatProvider: null,
25-
autoCreateSqlTable: true,
2644
columnOptions: null,
27-
schemaName: _schemaName,
2845
logEventFormatter: null)
2946
.CreateLogger();
3047

sample/CombinedConfigDemo/Program.cs

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

67
namespace CombinedConfigDemo
78
{
@@ -20,15 +21,32 @@ public static void Main()
2021
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
2122
.Build();
2223
var columnOptionsSection = configuration.GetSection("Serilog:ColumnOptions");
24+
var sinkOptionsSection = configuration.GetSection("Serilog:SinkOptions");
2325

26+
// Legacy interace - do not use this anymore
27+
//Log.Logger = new LoggerConfiguration()
28+
// .WriteTo.MSSqlServer(
29+
// connectionString: _connectionStringName,
30+
// tableName: _tableName,
31+
// appConfiguration: configuration,
32+
// autoCreateSqlTable: true,
33+
// columnOptionsSection: columnOptionsSection,
34+
// schemaName: _schemaName)
35+
// .CreateLogger();
36+
37+
// New SinkOptions based interface
2438
Log.Logger = new LoggerConfiguration()
2539
.WriteTo.MSSqlServer(
2640
connectionString: _connectionStringName,
27-
tableName: _tableName,
41+
sinkOptions: new SinkOptions
42+
{
43+
TableName = _tableName,
44+
SchemaName = _schemaName,
45+
AutoCreateSqlTable = true
46+
},
47+
sinkOptionsSection: sinkOptionsSection,
2848
appConfiguration: configuration,
29-
autoCreateSqlTable: true,
30-
columnOptionsSection: columnOptionsSection,
31-
schemaName: _schemaName)
49+
columnOptionsSection: columnOptionsSection)
3250
.CreateLogger();
3351

3452
Log.Information("Hello {Name} from thread {ThreadId}", Environment.GetEnvironmentVariable("USERNAME"), Thread.CurrentThread.ManagedThreadId);

sample/CombinedConfigDemo/appsettings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"LogDatabase": "Server=localhost;Database=LogTest;Integrated Security=SSPI;"
1111
},
1212
"Serilog": {
13+
"SinkOptions": {
14+
"batchPostingLimit": 5,
15+
"batchPeriod": "00:00:15"
16+
},
1317
"ColumnOptions": {
1418
"addStandardColumns": [ "LogEvent" ],
1519
"removeStandardColumns": [ "MessageTemplate", "Properties" ],

sample/CustomLogEventFormatterDemo/Program.cs

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

67
namespace CustomLogEventFormatterDemo
78
{
@@ -16,18 +17,37 @@ public static void Main()
1617
var options = new ColumnOptions();
1718
options.Store.Add(StandardColumn.LogEvent);
1819
var customFormatter = new FlatLogEventFormatter();
20+
21+
// Legacy interace - do not use this anymore
22+
//Log.Logger = new LoggerConfiguration()
23+
// .WriteTo.MSSqlServer(_connectionString,
24+
// _tableName,
25+
// appConfiguration: null,
26+
// restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Verbose,
27+
// batchPostingLimit: 50,
28+
// period: null,
29+
// formatProvider: null,
30+
// autoCreateSqlTable: true,
31+
// columnOptions: options,
32+
// columnOptionsSection: null,
33+
// schemaName: _schemaName,
34+
// logEventFormatter: customFormatter)
35+
// .CreateLogger();
36+
37+
// New SinkOptions based interface
1938
Log.Logger = new LoggerConfiguration()
2039
.WriteTo.MSSqlServer(_connectionString,
21-
_tableName,
40+
sinkOptions: new SinkOptions
41+
{
42+
TableName = _tableName,
43+
SchemaName = _schemaName,
44+
AutoCreateSqlTable = true
45+
},
2246
appConfiguration: null,
2347
restrictedToMinimumLevel: Serilog.Events.LogEventLevel.Verbose,
24-
batchPostingLimit: 50,
25-
period: null,
2648
formatProvider: null,
27-
autoCreateSqlTable: true,
2849
columnOptions: options,
2950
columnOptionsSection: null,
30-
schemaName: _schemaName,
3151
logEventFormatter: customFormatter)
3252
.CreateLogger();
3353

sample/WorkerServiceDemo/Worker.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
2121

2222
while (!stoppingToken.IsCancellationRequested)
2323
{
24-
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
24+
_logger.LogInformation("Worker running at: {time}. CustomProperty1: {CustomProperty1}",
25+
DateTimeOffset.Now, "Value");
2526
await Task.Delay(1000, stoppingToken);
2627
}
2728

sample/WorkerServiceDemo/appsettings.json

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,62 @@
1414
"Name": "MSSqlServer",
1515
"Args": {
1616
"connectionString": "Server=localhost;Database=LogTest;Integrated Security=SSPI;",
17-
"tableName": "LogEvents",
17+
"sinkOptionsSection": {
18+
"tableName": "LogEvents",
19+
"autoCreateSqlTable": true,
20+
"useAzureManagedIdentity": false,
21+
"azureServiceTokenProviderResource": "https://database.windpws.net/"
22+
},
23+
"restrictedToMinimumLevel": "Information",
1824
"columnOptionsSection": {
1925
"addStandardColumns": [ "LogEvent" ],
2026
"removeStandardColumns": [ "MessageTemplate", "Properties" ],
2127
"timeStamp": {
2228
"columnName": "Timestamp",
2329
"convertToUtc": false
24-
}
30+
},
31+
"additionalColumns": [
32+
{
33+
"columnName": "AdditionalColumn1",
34+
"propertyName": "CustomProperty1",
35+
"dataType": "12"
36+
}
37+
]
2538
},
26-
"autoCreateSqlTable": true,
27-
"restrictedToMinimumLevel": "Information",
2839
"logEventFormatter": "WorkerServiceDemo.CustomLogEventFormatter::Formatter, WorkerServiceDemo"
2940
}
3041
}
42+
],
43+
"AuditTo": [
44+
{
45+
"Name": "MSSqlServer",
46+
"Args": {
47+
"connectionString": "Server=localhost;Database=LogTest;Integrated Security=SSPI;",
48+
"restrictedToMinimumLevel": "Information",
49+
"logEventFormatter": "WorkerServiceDemo.CustomLogEventFormatter::Formatter, WorkerServiceDemo",
50+
"sinkOptionsSection": {
51+
"tableName": "LogEventsAudit",
52+
"autoCreateSqlTable": true,
53+
"useAzureManagedIdentity": false,
54+
"azureServiceTokenProviderResource": "https://database.windpws.net/"
55+
},
56+
"columnOptionsSection": {
57+
"addStandardColumns": [ "LogEvent" ],
58+
"removeStandardColumns": [ "MessageTemplate", "Properties" ],
59+
"timeStamp": {
60+
"columnName": "Timestamp",
61+
"convertToUtc": false
62+
},
63+
"additionalColumns": [
64+
{
65+
"columnName": "AdditionalColumn1",
66+
"propertyName": "CustomProperty1",
67+
"dataType": "12"
68+
}
69+
]
70+
}
71+
}
72+
}
3173
]
3274
}
3375
}

0 commit comments

Comments
 (0)