ASP.NET Core logging has this concept of 'Log event ID',
so that we can log lines like this (from their documentation);
_logger.LogInformation(LoggingEvents.GET_ITEM, "Getting item {ID}", id);
Serilog writes this inforamtion, LoggingEvents.GET_ITEM, in the properties column
<property key='EventId'>
<structure type=''>
<property key='Id'>1002</property>
</structure>
I've added a new column 'EventId' in the table in the database, and added this ColumnOptions to the logger
columnOptions.AdditionalDataColumns = new List<DataColumn>
{
new DataColumn {DataType = typeof(byte), ColumnName = "EventId"},
new DataColumn {DataType = typeof(string), ColumnName = "SessionId"}
};
But Serilog doesn't write anything to the database. Only when I remove this line:
new DataColumn {DataType = typeof(byte), ColumnName = "EventId"},
does Serilog write the line to the databse, but without the EventId column.
How can I write the event id?