{"action":"created","issue":{"url":"https://api.github.com/repos/NLog/NLog.Framework.Logging/issues/17","repository_url":"https://api.github.com/repos/NLog/NLog.Framework.Logging","labels_url":"https://api.github.com/repos/NLog/NLog.Framework.Logging/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/NLog/NLog.Framework.Logging/issues/17/comments","events_url":"https://api.github.com/repos/NLog/NLog.Framework.Logging/issues/17/events","html_url":"https://github.com/NLog/NLog.Framework.Logging/issues/17","id":133546499,"number":17,"title":"Filtering Logs","user":{"login":"mredman","id":6533238,"avatar_url":"https://avatars.githubusercontent.com/u/6533238?v=3","gravatar_id":"","url":"https://api.github.com/users/mredman","html_url":"https://github.com/mredman","followers_url":"https://api.github.com/users/mredman/followers","following_url":"https://api.github.com/users/mredman/following{/other_user}","gists_url":"https://api.github.com/users/mredman/gists{/gist_id}","starred_url":"https://api.github.com/users/mredman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mredman/subscriptions","organizations_url":"https://api.github.com/users/mredman/orgs","repos_url":"https://api.github.com/users/mredman/repos","events_url":"https://api.github.com/users/mredman/events{/privacy}","received_events_url":"https://api.github.com/users/mredman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-02-14T15:05:01Z","updated_at":"2016-02-14T15:21:27Z","closed_at":null,"body":"I am trying to implement NLog Logging in asp.net 5\r\nThe logging works but I am getting every log from the asp.net framework and would like to split these logs and my own application logs into separate log files.\r\nI am aware that this can be done using filtering, however I am expecting the ${callsite} to represent the namespace of my logger, so cannot filter the logs.\r\n\r\nStartup.cs:\r\n```c#\r\nloggerFactory.AddNLog();            \r\nenv.ConfigureNLog(\"nlog.config\");\r\n```\r\n\r\nnlog.config:\r\n```xml\r\n<nlog xmlns=\"http://www.nlog-project.org/schemas/NLog.xsd\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" throwExceptions=\"false\" autoReload=\"false\" internalLogFile=\"C:\\Development\\Logs\\NLog_Debug.txt\" internalLogLevel=\"Error\" internalLogToConsoleError=\"false\">\r\n  <targets async=\"true\">\r\n    <target name=\"AspNetLogFile\" xsi:type=\"File\" fileName=\"C:\\Development\\Logs\\AspNet_${date:format=yyyy-MM-dd}.log\" layout=\"${longdate:format=yyyy-MM-dd HH:mm:ss} ${level:uppercase=true:padding=5} ${callsite} ${message} ${exception:format=Message,StackTrace}\" maxArchiveFiles=\"30\" archiveAboveSize=\"10485760\" archiveNumbering=\"Rolling\" archiveEvery=\"Day\" />\r\n    <target name=\"ApplicationLogFile\" xsi:type=\"File\" fileName=\"C:\\Development\\Logs\\Web_${date:format=yyyy-MM-dd}.log\" layout=\"${longdate:format=yyyy-MM-dd HH:mm:ss} ${level:uppercase=true:padding=5} ${callsite} ${message} ${exception:format=Message,StackTrace}\" maxArchiveFiles=\"30\" archiveAboveSize=\"10485760\" archiveNumbering=\"Rolling\" archiveEvery=\"Day\" />\r\n  </targets>\r\n  <rules>\r\n    <logger name=\"*\" minlevel=\"Trace\" maxLevel=\"Error\" writeTo=\"ApplicationLogFile\">\r\n      <filters>\r\n        <when condition=\"starts-with('${logger}','App.')\" action=\"LogFinal\" />\r\n        <when condition=\"starts-with('${logger}','Web')\" action=\"LogFinal\" />\r\n      </filters>\r\n    </logger>\r\n    <logger name=\"*\" minlevel=\"Info\" maxLevel=\"Debug\" writeTo=\"AspNetLogFile\" />\r\n  </rules>\r\n</nlog>\r\n```\r\n\r\nI have 2 project, the web application where the namespace starts with Web. eg `Web.Controllers`\r\nand a class library project called App where the namespaces started with \"App.\"\r\n\r\nI have a base controller which as follows:\r\n\r\n```c#\r\nusing System;\r\nusing Microsoft.Extensions.Logging;\r\nusing Microsoft.Extensions.OptionsModel;\r\n\r\n\r\nnamespace App.Web.Mvc\r\n{\r\n    public class Controller : Microsoft.AspNet.Mvc.Controller\r\n    {\r\n        protected Settings Settings { get; }\r\n        protected ILogger Logger { get; }\r\n\r\n        public Controller(ILoggerFactory loggerFactory, IOptions<Settings> settings, IServiceProvider serviceProvider)\r\n        {\r\n            Logger = loggerFactory.CreateLogger(GetType().Namespace);\r\n            Settings = settings.Value;\r\n        }\r\n    }\r\n}\r\n\r\n```\r\nCalling: `Logger.LogInformation(\"Home/Index called\");` in my HomeController results in the following log:\r\n\r\n> 2016-02-14 14:31:03.4450  INFO Microsoft.Extensions.Logging.Logger.Log Home/Index called\r\n\r\nDoes this setup look correct? should I expect the callsite to not be Microsoft.Extensions.Logging.Logger.Log?"},"comment":{"url":"https://api.github.com/repos/NLog/NLog.Framework.Logging/issues/comments/183904758","html_url":"https://github.com/NLog/NLog.Framework.Logging/issues/17#issuecomment-183904758","issue_url":"https://api.github.com/repos/NLog/NLog.Framework.Logging/issues/17","id":183904758,"user":{"login":"304NotModified","id":5808377,"avatar_url":"https://avatars.githubusercontent.com/u/5808377?v=3","gravatar_id":"","url":"https://api.github.com/users/304NotModified","html_url":"https://github.com/304NotModified","followers_url":"https://api.github.com/users/304NotModified/followers","following_url":"https://api.github.com/users/304NotModified/following{/other_user}","gists_url":"https://api.github.com/users/304NotModified/gists{/gist_id}","starred_url":"https://api.github.com/users/304NotModified/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/304NotModified/subscriptions","organizations_url":"https://api.github.com/users/304NotModified/orgs","repos_url":"https://api.github.com/users/304NotModified/repos","events_url":"https://api.github.com/users/304NotModified/events{/privacy}","received_events_url":"https://api.github.com/users/304NotModified/received_events","type":"User","site_admin":false},"created_at":"2016-02-14T15:21:27Z","updated_at":"2016-02-14T15:21:27Z","body":"Tested it, and it works :smile: \r\n\r\nWith this config:\r\n\r\n```xml\r\n<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<nlog xmlns=\"http://www.nlog-project.org/schemas/NLog.xsd\"\r\n      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n      autoReload=\"true\"\r\n      internalLogLevel=\"Warn\"\r\n      internalLogFile=\"c:\\temp\\internal.txt\">\r\n\r\n  <extensions>\r\n  </extensions>\r\n\r\n  <!-- define various log targets -->\r\n  <targets>\r\n    <!-- write logs to file -->\r\n    <target xsi:type=\"File\" name=\"allfile\" fileName=\"c:\\temp\\nlog-all-${shortdate}.log\"\r\n                layout=\"${logger}|${longdate}|${uppercase:${level}}|${message}\" />\r\n\r\n\r\n    <target xsi:type=\"File\" name=\"ownFile\" fileName=\"c:\\temp\\nlog-own-${shortdate}.log\"\r\n              layout=\"${logger}|${longdate}|${uppercase:${level}}|${message}\" />\r\n\r\n    <target xsi:type=\"Null\" name=\"blackhole\" />\r\n  </targets>\r\n\r\n  <rules>\r\n    <!--All logs, including from Microsoft-->\r\n    <logger name=\"*\" minlevel=\"Trace\" writeTo=\"allfile\" />\r\n\r\n    <!--Skip Microsoft logs and so log only own logs-->\r\n    <logger name=\"Microsoft.*\" minlevel=\"Trace\" writeTo=\"blackhole\" final=\"true\" />\r\n    <logger name=\"*\" minlevel=\"Trace\" writeTo=\"ownFile\" />\r\n  </rules>\r\n</nlog>\r\n\r\n```"}}