Reputation: 3514
I am trying to read the application name from the App.Config. This is net461
console app. I have added the Serilog.Settings.AppSettings package. And also added the following serilog configs on App.Config
<add key="serilog:properties:Application" value="My App"/>
<add key="serilog:minimum-level" value="Debug" />
<add key="serilog:minimum-level:override:Microsoft" value="Debug" />
<add key="serilog:enrich:FromLogContext"/>
<add key="serilog:enrich:WithMachineName"/>
<add key="serilog:enrich:WithProcessId"/>
<add key="serilog:using:Seq" value="Serilog.Sinks.Seq"/>
<add key="serilog:write-to:Seq.serverUrl" value="http://localhost:5341" />
<add key="serilog:using:Console" value="Serilog.Sinks.Console" />
<add key="serilog:write-to:Console"/>
But the application name is not displaying on Seq. However, I have added the following settings on appsettings.json
for a .netcore2 project, this works as expected
"Serilog": {
"Properties": {
"Application": "Another app"
}
}
What is missing?
Upvotes: 7
Views: 9294
Reputation: 733
You can also achieve this in code with something like this:
builder.Services.AddSerilog((provider, loggerConfiguration) =>
{
...
loggerConfiguration.Enrich.WithProperty("Application", "My App");
...
}
Upvotes: 0
Reputation: 31832
I believe you need:
<add key="serilog:enrich:with-property:Application" value="My App" />
(Rather than "serilog:properties...
)
Upvotes: 8