File tree Expand file tree Collapse file tree 4 files changed +22
-0
lines changed Expand file tree Collapse file tree 4 files changed +22
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
1
2
using Microsoft . Extensions . DependencyInjection ;
2
3
using Microsoft . Extensions . Hosting ;
3
4
using Serilog ;
@@ -8,6 +9,7 @@ public static class Program
8
9
{
9
10
public static void Main ( string [ ] args )
10
11
{
12
+ //Serilog.Debugging.SelfLog.Enable(Console.Error);
11
13
CreateHostBuilder ( args ) . Build ( ) . Run ( ) ;
12
14
}
13
15
Original file line number Diff line number Diff line change
1
+ namespace WorkerServiceDemo
2
+ {
3
+ internal class Structured
4
+ {
5
+ public string Name { get ; set ; }
6
+ }
7
+ }
Original file line number Diff line number Diff line change @@ -19,6 +19,14 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
19
19
{
20
20
_logger . LogInformation ( "Worker started" ) ;
21
21
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
+
22
30
while ( ! stoppingToken . IsCancellationRequested )
23
31
{
24
32
_logger . LogInformation ( "Worker running at: {time}. CustomProperty1: {CustomProperty1}" ,
Original file line number Diff line number Diff line change 31
31
"columnName" : " AdditionalColumn1" ,
32
32
"propertyName" : " CustomProperty1" ,
33
33
"dataType" : " 12"
34
+ },
35
+ {
36
+ "columnName" : " AdditionalColumn2" ,
37
+ "propertyName" : " Structured.Name" ,
38
+ "dataType" : " 12"
34
39
}
35
40
]
36
41
},
You can’t perform that action at this time.
0 commit comments