4

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.

2
  • If you can provide some demo code, that would be better for other's understanding the issue. Commented Jan 18, 2019 at 1:56
  • Edited to add more info. Commented Jan 18, 2019 at 13:56

2 Answers 2

6

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

Sign up to request clarification or add additional context in comments.

Comments

0

Answered on GitHub: https://github.com/serilog/serilog-settings-configuration/issues/165. Just need to write an assembly and embed the final code there.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.