Skip to content

Commit 659374a

Browse files
committed
Added a sample of hierachical property expressions in WorkerServiceDemo
1 parent bea1891 commit 659374a

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

sample/WorkerServiceDemo/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using Microsoft.Extensions.DependencyInjection;
23
using Microsoft.Extensions.Hosting;
34
using Serilog;
@@ -8,6 +9,7 @@ public static class Program
89
{
910
public static void Main(string[] args)
1011
{
12+
//Serilog.Debugging.SelfLog.Enable(Console.Error);
1113
CreateHostBuilder(args).Build().Run();
1214
}
1315

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace WorkerServiceDemo
2+
{
3+
internal class Structured
4+
{
5+
public string Name { get; set; }
6+
}
7+
}

sample/WorkerServiceDemo/Worker.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
1919
{
2020
_logger.LogInformation("Worker started");
2121

22+
// Logging child property Name of structured object structured
23+
// to a separate column according to configuration in AddictionalColumns in appsettings.json
24+
var structured = new Structured
25+
{
26+
Name = "Structured Subproperty Value"
27+
};
28+
_logger.LogInformation("{@Structured} {@Scalar}", structured, "Scalar Value");
29+
2230
while (!stoppingToken.IsCancellationRequested)
2331
{
2432
_logger.LogInformation("Worker running at: {time}. CustomProperty1: {CustomProperty1}",

sample/WorkerServiceDemo/appsettings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
"columnName": "AdditionalColumn1",
3232
"propertyName": "CustomProperty1",
3333
"dataType": "12"
34+
},
35+
{
36+
"columnName": "AdditionalColumn2",
37+
"propertyName": "Structured.Name",
38+
"dataType": "12"
3439
}
3540
]
3641
},

0 commit comments

Comments
 (0)