For example right now I'm getting this log from serilog:
The query uses the 'First'/'FirstOrDefault' operator without 'OrderBy' and filter operators. This may lead to unpredictable results.
and this is it, no stacktrace, some File.cs and line number, nothing.
How do I make serilog write where this log has originated from (file, line number) ?
this is my current appsettings.json serilog configuration:
"Serilog": {
"MinimumLevel": {
"Default": "Information"
},
"WriteTo": [
{ "Name": "Console" },
{
"Name": "File",
"Args": {
"path": "./logs/log.json",
"rollingInterval": "Day",
"formatter": "Serilog.Formatting.Json.JsonFormatter, Serilog",
"restrictedToMinimumLevel": "Warning"
}
}
]
in Program.cs I'm setting it up like this:
builder.Host.UseSerilog(
(context, configuration) => configuration.ReadFrom.Configuration(context.Configuration));
You could try following sample: