{"action":"created","issue":{"url":"https://api.github.com/repos/NLog/NLog/issues/1998","repository_url":"https://api.github.com/repos/NLog/NLog","labels_url":"https://api.github.com/repos/NLog/NLog/issues/1998/labels{/name}","comments_url":"https://api.github.com/repos/NLog/NLog/issues/1998/comments","events_url":"https://api.github.com/repos/NLog/NLog/issues/1998/events","html_url":"https://github.com/NLog/NLog/issues/1998","id":211252589,"number":1998,"title":"NLog V4.4.2 abruptly stops logging for no apparent reason","user":{"login":"ReeceWilliams","id":8347704,"avatar_url":"https://avatars1.githubusercontent.com/u/8347704?v=3","gravatar_id":"","url":"https://api.github.com/users/ReeceWilliams","html_url":"https://github.com/ReeceWilliams","followers_url":"https://api.github.com/users/ReeceWilliams/followers","following_url":"https://api.github.com/users/ReeceWilliams/following{/other_user}","gists_url":"https://api.github.com/users/ReeceWilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/ReeceWilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ReeceWilliams/subscriptions","organizations_url":"https://api.github.com/users/ReeceWilliams/orgs","repos_url":"https://api.github.com/users/ReeceWilliams/repos","events_url":"https://api.github.com/users/ReeceWilliams/events{/privacy}","received_events_url":"https://api.github.com/users/ReeceWilliams/received_events","type":"User","site_admin":false},"labels":[{"id":13795221,"url":"https://api.github.com/repos/NLog/NLog/labels/bug","name":"bug","color":"fc2929","default":true},{"id":302859011,"url":"https://api.github.com/repos/NLog/NLog/labels/file-target","name":"file-target","color":"ffffff","default":false},{"id":180739971,"url":"https://api.github.com/repos/NLog/NLog/labels/must%20have","name":"must have","color":"000000","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/NLog/NLog/milestones/37","html_url":"https://github.com/NLog/NLog/milestone/37","labels_url":"https://api.github.com/repos/NLog/NLog/milestones/37/labels","id":2320217,"number":37,"title":"4.4.4","description":"","creator":{"login":"304NotModified","id":5808377,"avatar_url":"https://avatars2.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},"open_issues":6,"closed_issues":6,"state":"open","created_at":"2017-02-13T22:10:37Z","updated_at":"2017-03-05T19:15:17Z","due_on":null,"closed_at":null},"comments":11,"created_at":"2017-03-02T00:29:13Z","updated_at":"2017-03-08T20:45:45Z","closed_at":null,"body":"Bug\r\n**NLog version**:  4.4.2 and later\r\n**Platform**:  .Net 4.5\r\n**Current NLog config**\r\nWe have a C# batch process that connects to several different customer specific databases and we create a log file per database at start up.\r\nWe programmatically create log file targets based on the databases that the process connects to. The resultant log file instances are cached in a static class. The code we use is below.\r\n\r\nThis has all been working fine until (by a process of elimination) we went later than V4.4.1 - so 4.4.3 exhibits this as well, V4.4.1 works ok.\r\n\r\n\r\n\r\n```c#\r\npublic static bool AddDatabaseTarget(string dbName) {\r\n\tif (File.ContainsKey(dbName)) return false;\r\n\r\n\tvar config = LogManager.Configuration;\r\n\r\n\t// allow 10 database specific log files before rollover\r\n\tAddTarget(dbName, config, LogLevel.Info, 10);\r\n\tLogManager.Configuration = config;\r\n\r\n\tvar logFile = new LogFile(dbName);\r\n\tif (logFile.LogFileTargetValid) File.TryAdd(dbName, logFile);\r\n\treturn true;\r\n}\r\n\r\nprivate static void AddTarget(string dbName, LoggingConfiguration config, LogLevel level, int? maxArchiveFilesOverride = null)\r\n{\r\n\tvar atw = new AsyncTargetWrapper\r\n\t{\r\n\t\tName = dbName,\r\n\t\tWrappedTarget = new FileTarget\r\n\t\t{\r\n\t\t\tName = dbName,\r\n\t\t\tFileName = Path.Combine(RootLogFolder, dbName, dbName + \".log\"),\r\n\t\t\tArchiveFileName = Path.Combine(RootLogFolder, dbName, dbName + \".{#}.log\"),\r\n\t\t\tMaxArchiveFiles = maxArchiveFilesOverride ?? MaxArchiveFiles,\r\n\t\t\tArchiveAboveSize = ArchiveAboveSize,\r\n\t\t\tArchiveNumbering = ArchiveNumberingMode.Sequence,\r\n\t\t\tArchiveEvery = FileArchivePeriod.Day,\r\n\t\t\tKeepFileOpen = false,\r\n\t\t\tCreateDirs = true,\r\n\t\t\tLayout = \"${longdate} ${uppercase:${level}}\\t${message}\"\r\n\t\t}\r\n\t};\r\n\tLogManager.Configuration.AddTarget(dbName, atw);\r\n\tconfig.LoggingRules.Add(new LoggingRule(dbName, level, atw) { Final = true });\r\n}\r\n```\r\nThe effect is that logging just stops; it happily logs things out until a certain point when logging ceases.\r\n\r\nThe internal, info level log files are identical between V4.4.1 (which is working) and V4.4.2 (which stops logging):\r\n```\r\n2017-03-02 10:10:06.0238 Info Configured from an XML element in D:\\Batch\\Alerts\\AlertsGeneration.exe.Config...\r\n2017-03-02 10:10:06.2737 Info Found 0 configuration items\r\n2017-03-02 10:10:06.3832 Info Configuration initialized.\r\n2017-03-02 10:10:06.3987 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.4.4471. Product version: 4.4.2.\r\n2017-03-02 10:10:07.1019 Info Closing old configuration.\r\n2017-03-02 10:10:07.1175 Info Found 75 configuration items\r\n2017-03-02 10:10:07.1175 Info Found 75 configuration items\r\n2017-03-02 10:10:08.4456 Info Closing old configuration.\r\n2017-03-02 10:10:08.4456 Info Found 90 configuration items\r\n2017-03-02 10:10:08.4456 Info Found 90 configuration items\r\n2017-03-02 10:10:10.5550 Info Closing old configuration.\r\n\r\n<snip />\r\n\r\n2017-03-02 10:10:12.8988 Info Found 465 configuration items\r\n2017-03-02 10:10:12.9457 Info Found 465 configuration items\r\n2017-03-02 10:10:13.1957 Info Shutting down logging...\r\n2017-03-02 10:10:13.1957 Info Logger has been shut down.\r\n```\r\n\r\nHas something changed that is inadvertently limiting the number of log files you can generate at a time?\r\n\r\nI'm pretty sure we're up to 30 separate log files now.\r\nThanks.\r\n"},"comment":{"url":"https://api.github.com/repos/NLog/NLog/issues/comments/285163639","html_url":"https://github.com/NLog/NLog/issues/1998#issuecomment-285163639","issue_url":"https://api.github.com/repos/NLog/NLog/issues/1998","id":285163639,"user":{"login":"snakefoot","id":11509660,"avatar_url":"https://avatars0.githubusercontent.com/u/11509660?v=3","gravatar_id":"","url":"https://api.github.com/users/snakefoot","html_url":"https://github.com/snakefoot","followers_url":"https://api.github.com/users/snakefoot/followers","following_url":"https://api.github.com/users/snakefoot/following{/other_user}","gists_url":"https://api.github.com/users/snakefoot/gists{/gist_id}","starred_url":"https://api.github.com/users/snakefoot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snakefoot/subscriptions","organizations_url":"https://api.github.com/users/snakefoot/orgs","repos_url":"https://api.github.com/users/snakefoot/repos","events_url":"https://api.github.com/users/snakefoot/events{/privacy}","received_events_url":"https://api.github.com/users/snakefoot/received_events","type":"User","site_admin":false},"created_at":"2017-03-08T20:45:44Z","updated_at":"2017-03-08T20:45:44Z","body":"@ReeceWilliams Also I think it is bad idea to give both the AsyncTargetWrapper + FileTarget the same name. Instead it should be AsyncTargetWrapper.Name = dbName and FileTarget.Name = dbName + \"Wrapped\"."}}
{"actor":{"display_login":"snakefoot"}}