如何为 serilog 'WriteTo.Http'设置输出模板



2020-03-11 18:13:56.005+05:30 DESKTOP-4EE5SF ZZZ[INF]日志记录已启动。

当使用serilog将事件记录到文件中时,会给出上述日志消息。

Log.Logger = new LoggerConfiguration()
.WriteTo.File("",
rollingInterval: RollingInterval.Day,
fileSizeLimitBytes: 1024 * 100,
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} {MachineName} ZZZ[{Level:u3}] {Message:lj}{NewLine}{Exception})                   
.CreateLogger();
Log.Information("Logging started.");    

我如何使用Serilog HTTP记录器获得相同的输出,比如下面的

.WriteTo.Http(ConfigurationManager.AppSettings["httpLoggingPath"],
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} {MachineName} ZZZ[{Level:u3}] {Message:lj}{NewLine}{Exception})

不能,接收器不支持输出模板。

我对输出模板的看法是,它们适合为用户生成输出的接收器。当希望使用日志服务器(例如Logstash(集中日志事件时,HTTP接收器对于分布式计算来说更为必要。

我真的很想帮你。我们能把这个讨论转移到GitHub存储库的一个新问题上吗?

最新更新