Reputation: 1803
I am trying to use https://github.com/serilog/serilog-settings-configuration to read app settings and setup serilog for app insights: https://github.com/serilog/serilog-sinks-applicationinsights. The issue I am having is that I cannot set the last parameters for ApplicationInsightsEvents call, which is a function that takes LogEvent and returns ITelemetry. How can this be set via appsettings.json?
Basically, I want to replace the followoing line: log.WriteTo.ApplicationInsightsEvents(instrumentationKey, level, CultureInfo.CurrentCulture, TelemetryConverter.ConvertLogEventsToEnerGovTelemetry);
with a line inside appsettings.json
Thanks.
Upvotes: 4
Views: 5715
Reputation: 391
Add a sink configuration to appsettings.json
{
"Name": "ApplicationInsights",
"Args": {
"instrumentationKey": "<instrumentationKey>",
"telemetryConverter": "Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights",
"outputTemplate": "[{Component}|{MachineName}|{ThreadId}] {Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] <{SourceContext}> {Message:lj}{NewLine}{Exception}"
}
}
And
"Serilog.Sinks.ApplicationInsights"
to "Serilog:Using" array
Upvotes: 6
Reputation: 1803
Answered on GitHub: https://github.com/serilog/serilog-settings-configuration/issues/165. Just need to write an assembly and embed the final code there.
Upvotes: 0