serilog

What is Serilog destructuring?

微笑、不失礼 提交于 2020-12-03 06:27:18
问题 What is the purpose of Serilog's @ syntax? If I run the following: var dummy = new { Foo = "Bar", Date = DateTime.Now }; Log.Information("Dummy object: {Dummy}", dummy); Then I get an output to the console like so: Time: 16:20 [Level: Information] (ManagedThreadID: 8) Message: Dummy object: "Foo = Bar, Date = 25/06/2016 16:20:30 }" If I change the {Dummy} to {@Dummy} then I get the same output Time: 16:22 [Level: Information] (ManagedThreadID: 8) Message: Dummy object: Foo: "Bar", Date: 06/25

Serilog serializing fields

北城以北 提交于 2020-11-28 07:46:41
问题 If I have the following class public class Customer { public string Name; } and then have the following log command in Serilog Log.Logger = new LoggerConfiguration() .WriteTo.Console() .WriteTo.Seq("http://localhost:5341") .CreateLogger(); var item = new Customer(); item.Name = "John"; Serilog.Log.Information("Customer {@item}", item); The log just displays in Seq as Customer {} If I change the Name field to a property it works but I would prefer not to do that at this stage. Is there any way

Serilog serializing fields

江枫思渺然 提交于 2020-11-28 07:46:11
问题 If I have the following class public class Customer { public string Name; } and then have the following log command in Serilog Log.Logger = new LoggerConfiguration() .WriteTo.Console() .WriteTo.Seq("http://localhost:5341") .CreateLogger(); var item = new Customer(); item.Name = "John"; Serilog.Log.Information("Customer {@item}", item); The log just displays in Seq as Customer {} If I change the Name field to a property it works but I would prefer not to do that at this stage. Is there any way