I'm trying to set up serilog in some new projects. The problem is we have some legacy projects that use different custom logging solutions and I need logs to be in the same format as the old ones.
I'm using json configuration like this:
"Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId", "WithAssemblyName", "WithAssemblyVersion" ],
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "C:\\Logs\\EmailingService\\log.json",
"formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog",
"rollingInterval": "Day"
}
}
]
What I want is to change the output format of the Json file. I discovered here that I cannot use outputTemplate with JsonFormatter.
Right now my logs are like this:
{"Timestamp":"2020-07-17T07:34:36.4201803+02:00","Level":"Information","MessageTemplate":"Server instance started.","Properties":{"SourceContext":"DataSharingLibrary.Server.PipeServer","MachineName":"NTB","ProcessId":28024,"ThreadId":5,"AssemblyName":"EmalingService","AssemblyVersion":"1.0.0.0"}}
What I want is to move global enrichers out of the "properties" like this:
{"Timestamp":"2020-07-17T07:34:36.4201803+02:00","Level":"Information","MessageTemplate":"Server instance started.", "SourceContext":"DataSharingLibrary.Server.PipeServer","MachineName":"NTB","ProcessId":28024,"ThreadId":5,"AssemblyName":"EmalingService","AssemblyVersion":"1.0.0.0", "Properties":{...} }
What are my options? Do I have to write completly new ITextWritter for that? Use Nlog instead??