Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serilog doesn't log to Azure App Insights when deployed as an App Service #209

Open
Steve887 opened this issue Sep 18, 2022 · 1 comment
Labels

Comments

@Steve887
Copy link

I have a .Net Framework API and I am using Serilog with the Application Insights sink for logging.

I have configured Serilog with the AppInsights instrumentation key and using ILogger to trigger logging. When I run my API locally the log message show up in my App Insights Transaction search. However, when I deploy the API to an Azure App Service, the logs seem to never make it to App Insights.

I have tried updating the sink to latest, making sure the Instrumentation Key is correct but nothing seems to help.

My logging config:

var logConfig = new LoggerConfiguration()
    ReadFrom.AppSettings()
    WriteTo.ApplicationInsights(instrumentationKey, new TraceTelemetryConverter());
Log.Logger = logConfig.CreateLogger();

Then I'm using the following to test logging:

Log.Logger.Error("Log.Logger LogTest: Error");

I'm running out of ideas of where to go from here. Is there anything I'm missing?

@Steve887 Steve887 added the bug label Sep 18, 2022
@Ryanman
Copy link

Ryanman commented Nov 21, 2022

Might be a namespace conflict, I've been dealing with this as well.
https://stackoverflow.com/questions/72722971/getting-error-when-upgrading-from-serilog-sinks-applicationinsights-v3-1-to-v4-0

I got to the error by digging into the app logs for the service under "Diagnose and Solve Problems":

Exception Info: System.InvalidOperationException: Type Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights was not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants