17

RollingFile.outputTemplate我在配置中用于接收器的内容<appSettings>如下:

<add key="serilog:write-to:RollingFile.outputTemplate" value="{Timestamp:HH:mm:ss} [{Level}] {Message}{NewLine}{Exception}" />

我得到的输出日志为:

19:55:10 [Information] Application_Start...

但是,我还想输出生成日志的类名(源),例如 -

19:55:10 [Information] [Global.asax.cs] Application_Start...

我应该为“价值”添加什么?我添加了[Source]但无法正常工作。

value="{Timestamp:HH:mm:ss} [{Level}] [Source?] {Message}{NewLine}{Exception}"

4

1 回答 1

29

属性名称被称为SourceContext- 所以:

value="{Timestamp:HH:mm:ss} [{Level}] [{SourceContext}] {Message}{NewLine}{Exception}"
于 2015-01-26T03:10:14.110 回答