{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues/589","repository_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore","labels_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues/589/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues/589/comments","events_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues/589/events","html_url":"https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/589","id":292052778,"number":589,"title":"System.Diagnostics.Trace from referenced libs not showing","user":{"login":"spelltwister","id":4492581,"avatar_url":"https://avatars3.githubusercontent.com/u/4492581?v=4","gravatar_id":"","url":"https://api.github.com/users/spelltwister","html_url":"https://github.com/spelltwister","followers_url":"https://api.github.com/users/spelltwister/followers","following_url":"https://api.github.com/users/spelltwister/following{/other_user}","gists_url":"https://api.github.com/users/spelltwister/gists{/gist_id}","starred_url":"https://api.github.com/users/spelltwister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spelltwister/subscriptions","organizations_url":"https://api.github.com/users/spelltwister/orgs","repos_url":"https://api.github.com/users/spelltwister/repos","events_url":"https://api.github.com/users/spelltwister/events{/privacy}","received_events_url":"https://api.github.com/users/spelltwister/received_events","type":"User","site_admin":false},"labels":[{"id":856215268,"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/labels/logging","name":"logging","color":"c4193e","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-01-26T22:37:15Z","updated_at":"2018-03-06T10:18:25Z","closed_at":null,"author_association":"NONE","body":"I have a bunch of services which emit `System.Diagnostics.Trace.*` trace messages.  When hosted via ASP.NET WebAPI, I simply include the `Microsoft.ApplicationInsights.TraceListener` package and my custom traces from the service libs are collected in app insights.\r\n\r\nHowever, 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...\r\n\r\n### Add Application Insights\r\n    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)\r\n        {\r\n            loggerFactory.AddApplicationInsights(app.ApplicationServices, Microsoft.Extensions.Logging.LogLevel.Information);\r\n         //...\r\n        }\r\n\r\n## Expected Results\r\nTraces from both the framework and my libraries would be in the logs.\r\n\r\n## Actual Results\r\nAfter 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.\r\n\r\n### Add Trace Listener Package\r\nI 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...\r\n\r\n    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)\r\n        {\r\n            loggerFactory.AddTraceSource(new System.Diagnostics.SourceSwitch(\"AppInsightsTraceSwitch\")\r\n            {\r\n                Level = System.Diagnostics.SourceLevels.All\r\n            }, new Microsoft.ApplicationInsights.TraceListener.ApplicationInsightsTraceListener());\r\n\r\n            loggerFactory.AddApplicationInsights(app.ApplicationServices, Microsoft.Extensions.Logging.LogLevel.Information);\r\n        }\r\n\r\n## Expected Results\r\nTraces from both the framework and my libraries would be in the logs.\r\n\r\n## Actual Results\r\nAfter updating the configuration, I now see the framework trace messages duplicated in the logs, but none of the custom traces are present still.\r\n\r\n\r\n## Version Info \r\nSDK Version : \"Microsoft.ApplicationInsights.AspNetCore version 2.1.1\", also tried adding \"Microsoft.ApplicationInsights.TraceListener version 2.4.1\"\r\n.NET Version : \tnetcoreapp2.0\t\t\t\t\t\r\nHow Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) : Visual Studio\r\nOS : Windows 10\r\nHosting Info (IIS/Azure WebApps/ etc) : Azure App Services or locally on IIS have same behavior\r\nStackoverflow: https://stackoverflow.com/questions/48389908/application-insights-trace-listener-for-asp-net-core-2-0"},"comment":{"url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues/comments/370733400","html_url":"https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/589#issuecomment-370733400","issue_url":"https://api.github.com/repos/Microsoft/ApplicationInsights-aspnetcore/issues/589","id":370733400,"user":{"login":"cijothomas","id":5232798,"avatar_url":"https://avatars3.githubusercontent.com/u/5232798?v=4","gravatar_id":"","url":"https://api.github.com/users/cijothomas","html_url":"https://github.com/cijothomas","followers_url":"https://api.github.com/users/cijothomas/followers","following_url":"https://api.github.com/users/cijothomas/following{/other_user}","gists_url":"https://api.github.com/users/cijothomas/gists{/gist_id}","starred_url":"https://api.github.com/users/cijothomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cijothomas/subscriptions","organizations_url":"https://api.github.com/users/cijothomas/orgs","repos_url":"https://api.github.com/users/cijothomas/repos","events_url":"https://api.github.com/users/cijothomas/events{/privacy}","received_events_url":"https://api.github.com/users/cijothomas/received_events","type":"User","site_admin":false},"created_at":"2018-03-06T10:18:25Z","updated_at":"2018-03-06T10:18:25Z","author_association":"CONTRIBUTOR","body":"@spelltwister Hi,\r\nCan you share a small repro for us to investigate?\r\n```\r\n        loggerFactory.AddApplicationInsights(app.ApplicationServices, Microsoft.Extensions.Logging.LogLevel.Information);\r\n\r\n```\r\nThe above line is all you need to enable Trace collection."}}
{"actor":{"display_login":"cijothomas"}}