-
Notifications
You must be signed in to change notification settings - Fork 123
System.Diagnostics.Trace from referenced libs not showing #589
Comments
@spelltwister Hi,
The above line is all you need to enable Trace collection. |
I created the example repo here: https://github.com/spelltwister/AspNetCoreAppInsightsTrace. All you have to do is replace the value for instrumentation key in the appsettings.json file. There is only one controller with one method. Executing the method should call the service code which emits traces. None of the traces are captured in the local debug app insights data or in the app insights resource in azure. |
@spelltwister Thanks for sharing more details!
This enables capture of logs logged via ILogger interface of Asp.net Core (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?tabs=aspnetcore2x) Can you modify your app to use |
How could that be the recommended approach. Then my service libraries have to be dependant on asp.net logging. Is there anyway outside of this package to enable collection of traces? In the meantime, we've taken a dependency on app insights directly in our service libraries in order to get tracing back. I thought the point of tracing was to be able to sink it where ever. |
@spelltwister you could open an issue on the ApplicationInsights-dotnet-logging repo to add .NET Standard 2.0 support for TraceListener. (Note that it has to be netstandard2.0 because TraceListener wasn't in previous netstandard versions). See also microsoft/ApplicationInsights-dotnet-logging#115 which could be expanded to cover TraceListener. |
I created a PR to add a .NET Standard flavor of Microsoft.ApplicationInsights.TraceListener. See microsoft/ApplicationInsights-dotnet-logging#166 |
Thanks Pharring for addressing the issue! |
I have a bunch of services which emit
System.Diagnostics.Trace.*
trace messages. When hosted via ASP.NET WebAPI, I simply include theMicrosoft.ApplicationInsights.TraceListener
package and my custom traces from the service libs are collected in app insights.However, I cannot figure out how to get these same messages when hosting the services via ASP.NET Core 2.0 WebAPI. What I've tried...
Add Application Insights
Expected Results
Traces from both the framework and my libraries would be in the logs.
Actual Results
After adding application insights using the extension method, I am able to see the traces emitted by the framework (eg, Request Start, Request End, ...), but none of my custom trace messages are present.
Add Trace Listener Package
I decided to add in the
Microsoft.ApplicationInsights.TraceListener
package just to see if that would help. I updated the configure method to look like this...Expected Results
Traces from both the framework and my libraries would be in the logs.
Actual Results
After updating the configuration, I now see the framework trace messages duplicated in the logs, but none of the custom traces are present still.
Version Info
SDK Version : "Microsoft.ApplicationInsights.AspNetCore version 2.1.1", also tried adding "Microsoft.ApplicationInsights.TraceListener version 2.4.1"
.NET Version : netcoreapp2.0
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) : Visual Studio
OS : Windows 10
Hosting Info (IIS/Azure WebApps/ etc) : Azure App Services or locally on IIS have same behavior
Stackoverflow: https://stackoverflow.com/questions/48389908/application-insights-trace-listener-for-asp-net-core-2-0
The text was updated successfully, but these errors were encountered: