{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Logging/issues/369","repository_url":"https://api.github.com/repos/aspnet/Logging","labels_url":"https://api.github.com/repos/aspnet/Logging/issues/369/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Logging/issues/369/comments","events_url":"https://api.github.com/repos/aspnet/Logging/issues/369/events","html_url":"https://github.com/aspnet/Logging/issues/369","id":135839878,"number":369,"title":"Make filtering a first class citizen and remove provider specific filters","user":{"login":"cwe1ss","id":4581460,"avatar_url":"https://avatars.githubusercontent.com/u/4581460?v=3","gravatar_id":"","url":"https://api.github.com/users/cwe1ss","html_url":"https://github.com/cwe1ss","followers_url":"https://api.github.com/users/cwe1ss/followers","following_url":"https://api.github.com/users/cwe1ss/following{/other_user}","gists_url":"https://api.github.com/users/cwe1ss/gists{/gist_id}","starred_url":"https://api.github.com/users/cwe1ss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cwe1ss/subscriptions","organizations_url":"https://api.github.com/users/cwe1ss/orgs","repos_url":"https://api.github.com/users/cwe1ss/repos","events_url":"https://api.github.com/users/cwe1ss/events{/privacy}","received_events_url":"https://api.github.com/users/cwe1ss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-02-23T19:35:09Z","updated_at":"2016-02-25T05:40:56Z","closed_at":null,"body":"There is an ongoing discussion about the noise of log events here: #359 - I created this new issue because it discusses a specific solution - I hope that's ok! I will just provide an overview for people who haven't seen the other conversation.\r\n\r\nI strongly believe that this ILogger will be used *a lot* in many libraries and applications in the future. For this reason, being able to filter logs based on their namespace will be a very important topic.\r\n \r\nRight now, there is no clear recommendation. I read a few times that we should forward everything to another logger (Serilog, log4net, ...) and do the filtering there. However, there are also providers who already provide filtering mechanisms (e.g. ConsoleLogger). \r\nI'm sure this library will get many more first class providers (Application Insights, DB, ...) in the future, which would remove the need to have a 3rd party logger like Serilog/log4net. However, each provider has to decide about whether and how to implement filtering. This will result in a chaos where each provider must be configured differently or doesn't support filtering at all.\r\n\r\nDuring the discussion in the other thread, @lodejard [created an example FilterLogger](https://github.com/aspnet/Logging/commit/bf2314a9a139ae04fd7310d5df99b0cbe968ae35#diff-459e7bd4d619a1efc2739dff9398cf91R28) which acts as a LoggerFactory-wrapper and can be used like this:\r\n\r\n```csharp\r\n/// How to wrap filtering provider around other providers factory\r\nloggerFactory\r\n\t.WithFilter(new FilterLoggerSettings\r\n\t{\r\n\t\t{ \"Microsoft\", LogLevel.Warning },\r\n\t\t{ \"System\", LogLevel.Warning },\r\n\t\t{ \"SampleApp.Program\", LogLevel.Debug },\r\n\t})\r\n\t.AddEventLog();\r\n```\r\n\r\nI really like this concept and would love to see something like this included as a core concept for v1 because it has many important advantages:\r\n* You could completely remove the provider specific filters from ConsoleLogger etc.\r\n* Writing new providers would be very easy too (which leads to fast adaption)\r\n* Every provider would support this feature automatically\r\n* There would be a consistent API\r\n* There's no cost to it if you don't want to use it.\r\n\r\nI'm sure this would remove the need to have another logger (Serilog, ...) for most people! (since providers for most used targets will show up over time)\r\n\r\nAs an example, here's my real-life scenario:\r\n* Console: We usually don't output anything in Production but we have it running in no-op mode so that we can turn it on in case we need to do some on-server troubshooting (shouldn't happen though :-) ...). In Development, this is the most important provider and we constantly change the levels and namespaces based on our needs.\r\n* We log application startup errors in Production to EventLog in case our persistent store (e.g. Application Insights) isn't available (or didn't initialize correctly). This way we can still have some monitoring for startup crashes. We also have it enabled in Development to make sure it works. Right now we log \"Critical\" for everything and \"Error\" for Microsoft.AspNet.Hosting (because [startup errors are not considered critical right now](https://github.com/aspnet/Hosting/issues/612) )\r\n* We use a persistent log store (e.g. Application Insights, Stackify, ...) for our production environment. We log almost everything for our namespace but only \"Warning+\" for Microsoft. We might have to change the level based on our needs. In Development, we only send a little bit to make sure it works."},"comment":{"url":"https://api.github.com/repos/aspnet/Logging/issues/comments/188622826","html_url":"https://github.com/aspnet/Logging/issues/369#issuecomment-188622826","issue_url":"https://api.github.com/repos/aspnet/Logging/issues/369","id":188622826,"user":{"login":"ejsmith","id":282584,"avatar_url":"https://avatars.githubusercontent.com/u/282584?v=3","gravatar_id":"","url":"https://api.github.com/users/ejsmith","html_url":"https://github.com/ejsmith","followers_url":"https://api.github.com/users/ejsmith/followers","following_url":"https://api.github.com/users/ejsmith/following{/other_user}","gists_url":"https://api.github.com/users/ejsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/ejsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejsmith/subscriptions","organizations_url":"https://api.github.com/users/ejsmith/orgs","repos_url":"https://api.github.com/users/ejsmith/repos","events_url":"https://api.github.com/users/ejsmith/events{/privacy}","received_events_url":"https://api.github.com/users/ejsmith/received_events","type":"User","site_admin":false},"created_at":"2016-02-25T05:40:56Z","updated_at":"2016-02-25T05:40:56Z","body":"OK, sounds good. :-)"}}