Add custom properties to Serilog

后端 未结 3 1197
名媛妹妹
名媛妹妹 2021-02-01 18:09

I\'m using Serilog with an MS SQL Server sink in my application. Let\'s assume I have defined the following class ...

public class Person
{
  public string First         


        
3条回答
  •  终归单人心
    2021-02-01 18:45

    This is as simple as:

    Log.ForContext("BirthDate", person.BirthDate)
       .Information("New user: {FirstName:l} {LastName:l}",
                               person.FirstName, person.LastName);
    

提交回复
热议问题