In a .Net Core Webapi project I am using Serilog to log. But when I use _logger.LogInformation("Token for user {UserName} created",data.username); and check the log file, the output is "Token for user {Username} created". The {Username} is not replaced with the real value. I am sure that the value is not null.
I use this in a LoginService and the Serilog setting in the appsetting.json is
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Microsoft": "Information",
"System": "Information"
}
},
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": "C:\\Users\\ab\\Projects\\IQC\\IQC_Log.txt",
"rollingInterval": "Day",
"rollOnFileSizeLimit": true,
"formatter": "Serilog.Formatting.Compact.CompactJsonFormatter"
}
}
]
}
Could someone help to point out where I did wrong?