Skip to content

Commit 727e9a9

Browse files
committed
Adapted CombinedConfigDemo with newest Serilog packages to reproduce the problem.
1 parent 18f9194 commit 727e9a9

File tree

5 files changed

+23
-26
lines changed

5 files changed

+23
-26
lines changed

sample/CombinedConfigDemo/CombinedConfigDemo.csproj

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

1414
<ItemGroup>
1515
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.4" />
16+
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
1617
</ItemGroup>
1718

1819
<ItemGroup>

sample/CombinedConfigDemo/Program.cs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Threading;
1+
using System.Diagnostics;
32
using Microsoft.Extensions.Configuration;
43
using Serilog;
54
using Serilog.Sinks.MSSqlServer.Sinks.MSSqlServer.Options;
@@ -23,37 +22,35 @@ public static void Main()
2322
var columnOptionsSection = configuration.GetSection("Serilog:ColumnOptions");
2423
var sinkOptionsSection = configuration.GetSection("Serilog:SinkOptions");
2524

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();
25+
Serilog.Debugging.SelfLog.Enable(m => Debug.WriteLine(m));
3626

3727
// New SinkOptions based interface
38-
Log.Logger = new LoggerConfiguration()
28+
using (var logger = new LoggerConfiguration()
29+
.WriteTo.Console()
3930
.WriteTo.MSSqlServer(
4031
connectionString: _connectionStringName,
4132
sinkOptions: new SinkOptions
4233
{
4334
TableName = _tableName,
4435
SchemaName = _schemaName,
45-
AutoCreateSqlTable = true
36+
AutoCreateSqlTable = false
4637
},
4738
sinkOptionsSection: sinkOptionsSection,
4839
appConfiguration: configuration,
4940
columnOptionsSection: columnOptionsSection)
50-
.CreateLogger();
51-
52-
Log.Information("Hello {Name} from thread {ThreadId}", Environment.GetEnvironmentVariable("USERNAME"), Thread.CurrentThread.ManagedThreadId);
53-
54-
Log.Warning("No coins remain at position {@Position}", new { Lat = 25, Long = 134 });
55-
56-
Log.CloseAndFlush();
41+
.CreateLogger())
42+
{
43+
logger.Information("Log 1");
44+
logger.Information("Log 2");
45+
logger.Information("Log 3");
46+
logger.Information("Log 4");
47+
logger.Information("Log 5");
48+
logger.Information("Log 6");
49+
logger.Information("Log 7");
50+
logger.Information("Log 8");
51+
logger.Information("Log 9");
52+
logger.Information("Log 10");
53+
}
5754
}
5855
}
5956
}

sample/CombinedConfigDemo/appsettings.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
},
1212
"Serilog": {
1313
"SinkOptions": {
14-
"batchPostingLimit": 5,
15-
"batchPeriod": "00:00:15"
14+
"batchPostingLimit": 500
1615
},
1716
"ColumnOptions": {
1817
"addStandardColumns": [ "LogEvent" ],

src/Serilog.Sinks.MSSqlServer/Serilog.Sinks.MSSqlServer.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
<PrivateAssets>all</PrivateAssets>
3636
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3737
</PackageReference>
38-
<PackageReference Include="Serilog" Version="2.5.0" />
39-
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.1.1" />
38+
<PackageReference Include="Serilog" Version="2.9.0" />
39+
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.3.0" />
4040
</ItemGroup>
4141

4242
<ItemGroup>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Serilog" version="2.5.0" targetFramework="net452" />
4-
<package id="Serilog.Sinks.PeriodicBatching" version="2.1.1" targetFramework="net452" />
4+
<package id="Serilog.Sinks.PeriodicBatching" version="2.3.0" targetFramework="net452" />
55
<package id="System.Data.SqlClient" Version="4.6.0" targetFramework="net452" />
66
</packages>

0 commit comments

Comments
 (0)