{"action":"opened","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/5755","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/5755/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/5755/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/5755/events","html_url":"https://github.com/dotnet/corefx/issues/5755","id":129616203,"number":5755,"title":"System.Net EventSources conflict, reducing total logging","user":{"login":"bartonjs","id":10642668,"avatar_url":"https://avatars.githubusercontent.com/u/10642668?v=3","gravatar_id":"","url":"https://api.github.com/users/bartonjs","html_url":"https://github.com/bartonjs","followers_url":"https://api.github.com/users/bartonjs/followers","following_url":"https://api.github.com/users/bartonjs/following{/other_user}","gists_url":"https://api.github.com/users/bartonjs/gists{/gist_id}","starred_url":"https://api.github.com/users/bartonjs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartonjs/subscriptions","organizations_url":"https://api.github.com/users/bartonjs/orgs","repos_url":"https://api.github.com/users/bartonjs/repos","events_url":"https://api.github.com/users/bartonjs/events{/privacy}","received_events_url":"https://api.github.com/users/bartonjs/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/corefx/labels/System.Net","name":"System.Net","color":"d4c5f9"}],"state":"open","locked":false,"assignee":{"login":"CIPop","id":8635911,"avatar_url":"https://avatars.githubusercontent.com/u/8635911?v=3","gravatar_id":"","url":"https://api.github.com/users/CIPop","html_url":"https://github.com/CIPop","followers_url":"https://api.github.com/users/CIPop/followers","following_url":"https://api.github.com/users/CIPop/following{/other_user}","gists_url":"https://api.github.com/users/CIPop/gists{/gist_id}","starred_url":"https://api.github.com/users/CIPop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CIPop/subscriptions","organizations_url":"https://api.github.com/users/CIPop/orgs","repos_url":"https://api.github.com/users/CIPop/repos","events_url":"https://api.github.com/users/CIPop/events{/privacy}","received_events_url":"https://api.github.com/users/CIPop/received_events","type":"User","site_admin":false},"milestone":null,"comments":0,"created_at":"2016-01-28T23:25:24Z","updated_at":"2016-01-28T23:25:24Z","closed_at":null,"body":"Given:\r\n```C#\r\n    internal class ConsoleEventListener : EventListener\r\n    {\r\n        private static string[] s_optOut =\r\n        {\r\n            \"System.Threading.Tasks.TplEventSource\",\r\n            \"System.Diagnostics.Eventing.FrameworkEventSource\",\r\n        };\r\n\r\n        public ConsoleEventListener()\r\n        {\r\n            foreach (EventSource source in EventSource.GetSources())\r\n            {\r\n                if (Array.IndexOf(s_optOut, source.Name) == -1)\r\n                {\r\n                    EnableEvents(source, EventLevel.LogAlways);\r\n                }\r\n            }\r\n        }\r\n\r\n        protected override void OnEventSourceCreated(EventSource eventSource)\r\n        {\r\n            base.OnEventSourceCreated(eventSource);\r\n\r\n            if (Array.IndexOf(s_optOut, eventSource.Name) == -1)\r\n            {\r\n                EnableEvents(eventSource, EventLevel.LogAlways, EventKeywords.All);\r\n            }\r\n        }\r\n\r\n        protected override void OnEventWritten(EventWrittenEventArgs eventData)\r\n        {\r\n            Console.Write(\"Event \");\r\n            Console.Write(eventData.EventSource.Name);\r\n            Console.Write('-');\r\n            Console.Write(eventData.EventId);\r\n            Console.Write(\"  (\");\r\n\r\n            if (eventData.Payload != null)\r\n            {\r\n                bool writeComma = false;\r\n\r\n                foreach (object value in eventData.Payload)\r\n                {\r\n                    if (writeComma)\r\n                    {\r\n                        Console.Write(\", \");\r\n                    }\r\n\r\n                    Console.Write(value);\r\n                    writeComma = true;\r\n                }\r\n            }\r\n\r\n            Console.WriteLine(\").\");\r\n        }\r\n    }\r\n```\r\n\r\nOpen an instance of the logger, then proceed to open a TcpListener and a (client) SslStream.  Notice that many of the logs appear to be missing, which is likely due to:\r\n\r\n```\r\n...\r\nEvent Microsoft-System-Net-Debug-1  (Dns.GetHostName).\r\nEvent Microsoft-System-Net-Debug-0  (ERROR: Exception in Command Processing for EventSource Microsoft-System-Net-Debug: An instance of EventSource with Guid 99e4576b-9d7e-585f-8b32-0ac3082f2282 already exists.).\r\n...\r\nEvent Microsoft-System-Net-1  (System.Net.Sockets.Socket, 55915408, BeginConnect, localhost, 0, 0).\r\nEvent Microsoft-System-Net-0  (ERROR: Exception in Command Processing for EventSource Microsoft-System-Net: An instance of EventSource with Guid 501a994a-eb63-5415-9af1-1b031260f16c already exists.).\r\n...\r\nEvent Microsoft-System-Net-2  (System.Net.Sockets.TcpClient, 43495525, GetStream, System.Net.Sockets.NetworkStream, 2606490, 0).\r\nEvent Microsoft-System-Net-Debug-0  (ERROR: Exception in Command Processing for EventSource Microsoft-System-Net-Debug: An instance of EventSource with Guid 99e4576b-9d7e-585f-8b32-0ac3082f2282 already exists.).\r\n...\r\n```\r\n\r\nEach of the event 0 events seems to be a place where the next System.Net library woke up and tried logging something, and then that event source never gets activated due to a duplicate registration.\r\n\r\nLooks to be true for both Windows and Linux."}}