{"action":"created","issue":{"url":"https://api.github.com/repos/NLog/NLog/issues/1588","repository_url":"https://api.github.com/repos/NLog/NLog","labels_url":"https://api.github.com/repos/NLog/NLog/issues/1588/labels{/name}","comments_url":"https://api.github.com/repos/NLog/NLog/issues/1588/comments","events_url":"https://api.github.com/repos/NLog/NLog/issues/1588/events","html_url":"https://github.com/NLog/NLog/issues/1588","id":169765530,"number":1588,"title":"Configure from JSON instead of XML","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},"labels":[{"url":"https://api.github.com/repos/NLog/NLog/labels/discussion","name":"discussion","color":"006b75"},{"url":"https://api.github.com/repos/NLog/NLog/labels/feature","name":"feature","color":"02e10c"},{"url":"https://api.github.com/repos/NLog/NLog/labels/nlog-configuration","name":"nlog-configuration","color":"ffffff"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-08-06T20:40:32Z","updated_at":"2016-08-10T18:26:31Z","closed_at":null,"body":"Feature,\r\n\r\nConfigure NLog from a JSON format. \r\n\r\n## todo\r\n\r\n### How to handle the multiple XML elements to a dict/list? \r\n\r\n e.g. \r\n```xml\r\n    <parameter name=\"@msg\" layout=\"${message}\" />\r\n    <parameter name=\"@level\" layout=\"${level}\" />\r\n```\r\n to \r\n\r\n```json\r\n   \"parameters\": {\r\n        \"@msg\": \"${message}\",\r\n        \"@level\": \"${level}\",\r\n      },\r\n```\r\n\r\n### \"XSD\"\r\n\r\nHow to generate the schema def? How does this work with objects?\r\n\r\n## Large Example\r\nSomething like this:\r\n\r\n```json\r\n{\r\n  \"internalLog\": {\r\n    \"level\": \"Trace\",\r\n    \"file\": \"d:\\\\work\\\\log.txt\"\r\n  },\r\n  \"autoReload\": \"true\",\r\n  \"variables\": {\r\n    \"gmailUsername\": \"${trim-whitespace:${file-contents:${basedir}/gmailusername.txt}}\",\r\n    \"gmailPassword\": \"${trim-whitespace:${file-contents:${basedir}/gmailpassword.txt}}\"\r\n  },\r\n  \"extensions\": {\r\n    \"NLog.Extended\": {},\r\n    \"Custom\": {\r\n      \"filePath\": \"...\"\r\n    }\r\n  },\r\n  \"targets\": {\r\n    \"file\": {\r\n      \"type\": \"File\",\r\n      \"fileName\": \"${basedir}/logs/${shortdate}.log\",\r\n      \"layout\": \"${longdate} ${aspnet-request:servervariable=URL} ${uppercase:${level}} ${message}\"\r\n    },\r\n    \"db\": {\r\n      \"type\": \"Database\",\r\n      \"commandText\": \"INSERT INTO [LogEntries](TimeStamp, Message, Level, Logger) VALUES(getutcdate(), @msg, @level, @logger)\",\r\n      //todo how to rename? (was no list/dict here)\r\n      \"parameters\": {\r\n        \"@msg\": \"${message}\",\r\n        \"@level\": \"${level}\",\r\n        \"@logger\": \"${logger}\"\r\n      },\r\n      \"dbProvider\": \"System.Data.SqlClient\",\r\n      \"connectionString\": \"server=.\\\\SQLEXPRESS;database=MyLogs;integrated security=sspi\",\r\n      \"install-commands\": [\r\n        {\r\n          \"text\": \"CREATE DATABASE MyLogs\",\r\n          \"connectionString\": \"server=.\\\\SQLEXPRESS;database=master;integrated security=sspi\",\r\n          \"ignoreFailures\": \"true\"\r\n        },\r\n        {\r\n          \"text\": \"CREATE TABLE LogEntries( id int primary key not null identity(1,1), TimeStamp datetime2, Message nvarchar(max), level nvarchar(10), logger nvarchar(128))\"\r\n        }\r\n      ],\r\n      \"uninstall-commands\": [\r\n        {\r\n          \"text\": \"DROP DATABASE MyLogs\",\r\n          \"connectionString\": \"server=.\\\\SQLEXPRESS;database=master;integrated security=sspi\",\r\n          \"ignoreFailures\": \"true\"\r\n        }\r\n      ]\r\n    },\r\n    \"eventLog\": {\r\n      \"type\": \"EventLog\",\r\n      \"source\": \"NLog Demo\",\r\n      \"layout\": \"${message}${newline}Call site: ${callsite:className=true:methodName=true}${newline}Logger: ${logger}\"\r\n    },\r\n    \"pc1\": {\r\n      \"type\": \"PerfCounter\",\r\n      \"categoryName\": \"My Log\",\r\n      \"counterName\": \"My Counter\"\r\n    },\r\n    \"mail\": {\r\n      \"type\": \"Mail\",\r\n      \"smtpServer\": \"smtp.gmail.com\",\r\n      \"smtpPort\": \"587\",\r\n      \"enableSsl\": \"true\",\r\n      \"smtpAuthentication\": \"Basic\",\r\n      \"smtpUserName\": \"${gmailUsername}\",\r\n      \"smtpPassword\": \"${gmailPassword}\",\r\n      \"from\": \"${gmailUsername}\",\r\n      \"to\": \"${gmailUsername}\",\r\n      \"subject\": \"NLogDemo logs\",\r\n      \"addNewLines\": \"true\"\r\n    },\r\n    \"asyncMail\": {\r\n      \"type\": \"AsyncWrapper\",\r\n      \"wraps\": [ \"mail\" ]\r\n\r\n    },\r\n    //no anounous wrappers\r\n    \"postFilteringWrapper\": {\r\n      \"type\": \"PostFilteringWrapper\",\r\n      \"wraps\": [ \"splitGroup\" ],\r\n      \"defaultFilter\": \"level >= LogLevel.Info\",\r\n      //todo\r\n      \"when\": {\r\n        \"exists\": \"level >= LogLevel.Error\",\r\n        \"filter\": \"level >= LogLevel.Trace\"\r\n      }\r\n    },\r\n    \"splitGroup\": {\r\n      \"type\": \"SplitGroup\",\r\n      \"wraps\": [\r\n        \"file\",\r\n        \"db\",\r\n        \"eventLog\",\r\n        \"pc1\",\r\n        \"asyncMail\"\r\n      ]\r\n    },\r\n    \"allOutputs\": {\r\n      \"type\": \"AspNetBufferingWrapper\",\r\n      \"wraps\": [ \"PostFilteringWrapper\" ]\r\n    }\r\n\r\n  },\r\n  \"rules\": [\r\n    {\r\n      \"filter\": {\r\n        \"loggerName\": \"*\" //optional,\r\n        \"minLevel\": \"Trace\"\r\n      },\r\n      \"writeTo\": \"allOutputs\"\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\nchanges:\r\n\r\n- more flat, all targets must have names\r\n- internallog to object\r\n\r\n\r\n95% conversion from https://github.com/NLog/NLog/wiki/NLog-config-Example\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nMore generic feature: https://github.com/NLog/NLog/issues/951"},"comment":{"url":"https://api.github.com/repos/NLog/NLog/issues/comments/238958428","html_url":"https://github.com/NLog/NLog/issues/1588#issuecomment-238958428","issue_url":"https://api.github.com/repos/NLog/NLog/issues/1588","id":238958428,"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-08-10T18:26:31Z","updated_at":"2016-08-10T18:26:31Z","body":"Thanks! \r\n\r\nI'm Also curious after feedback on the json example. Is it good? Is it better then the XML? What could be better?"}}
{"actor":{"display_login":"304NotModified"}}