最后我找到了答案:我刚刚从表中删除了 Message 列,因为它通过使用这样的 xml 配置考虑了一个令人震惊的列
<RemoveStandardColumns>
**<remove Name="Message"/>**
<remove Name="MessageTemplate"/>
<remove Name="Level"/>
<remove Name="LogEvent"/>
<remove Name="Exception"/>
<remove Name="TimeStamp"/>
</RemoveStandardColumns>
然后将其再次添加为 c# 中的普通列,使用
new SqlColumn
{ColumnName = "Message", DataType = SqlDbType.VarChar, DataLength = 1024},
然后使用 serilog 将数据日志添加到此表中,我使用了以下内容
try
{
int b = 0;
int a = 1 / b;
}
catch (Exception ex)
{
int x = OccuranceCalc("SCA");
Log.ForContext("Message", "some Message")
.ForContext("LikeExpression", ex.Message)
.ForContext("OccurrenceCount", 1)
.ForContext("LastOccurrence", DateTime.Now)
.Fatal("{StackTrace}", ex.StackTrace);
}