Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

The Current Output of RollingFile Sink for Date time is as follows

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

Is there anyway to remove the TimeZone Offset? +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.

like image 587
Aaron Glover Avatar asked Apr 06 '15 13:04

Aaron Glover


1 Answers

You can specify the outputTemplate parameter to the .RollingFile() configuration method:

.WriteTo.RollingFile(
    outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level}] {Message}{NewLine}{Exception}")
like image 81
Nicholas Blumhardt Avatar answered Nov 03 '22 07:11

Nicholas Blumhardt