简体   繁体   English

Serilog-可以在RollingFile Sink中更改DateTime / Timestamp格式

[英]Serilog - Possible to Change DateTime/Timestamp Format in RollingFile Sink

The Current Output of RollingFile Sink for Date time is as follows Date时间的RollingFile Sink的当前输出如下

2015-04-06 18:40:54.400 +10:00 [Information] Hello World!

Is there anyway to remove the TimeZone Offset? 无论如何,有没有要删除“时区偏移”的内容? +10:00 . +10:00 To Achieve the following output; 实现以下输出;

2015-04-06 18:40:54.400 [Information] Hello World!

In my case, the timezone offset is superfluous fluff which is just cluttering my Text Log. 就我而言,时区偏移是多余的绒毛,这只会使我的文本日志混乱。

You can specify the outputTemplate parameter to the .RollingFile() configuration method: 您可以为.RollingFile()配置方法指定outputTemplate参数:

.WriteTo.RollingFile(
    outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level}] {Message}{NewLine}{Exception}")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM