{"id":708,"date":"2015-11-24T02:07:59","date_gmt":"2015-11-23T17:07:59","guid":{"rendered":"http:\/\/gomocool.net\/gomokulog\/?p=708"},"modified":"2015-11-24T02:07:59","modified_gmt":"2015-11-23T17:07:59","slug":"%e3%81%96%e3%81%a3%e3%81%8f%e3%82%8anlog","status":"publish","type":"post","link":"https:\/\/gomokulog.gomocool.net\/?p=708","title":{"rendered":"\u3056\u3063\u304f\u308aNLog"},"content":{"rendered":"<p>VisualStudio \u3067\u30ed\u30b0\u51fa\u529b\u3092\u3059\u308b\u306a\u3089\u3001NLog\u304c\u30aa\u30b9\u30b9\u30e1\u3002<\/p>\n<p>VisualStudio2013\u3001VisualStudio2015\u306a\u3089\u3001NuGet\u3067\u7c21\u5358\u306b\u5c0e\u5165\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u300c\u3081\u3093\u3069\u304f\u3055\u3044\u3053\u3068\u899a\u3048\u305a\u306b\u3001\u3068\u306b\u304b\u304f\u30ed\u30b0\u3092\u51fa\u3057\u305f\u3044\u3093\u3060\uff01\u300d\u3063\u3066\u65b9\u306b\u672c\u5f53\u306b\u30aa\u30b9\u30b9\u30e1\u3002<\/p>\n<p>\u307e\u305a\u3001NuGet\u30d1\u30c3\u30b1\u30fc\u30b8\u306e\u7ba1\u7406\u3092\u8d77\u52d5<\/p>\n<p><a href=\"http:\/\/gomocool.net\/gomokulog\/wp-content\/uploads\/2015\/11\/nlog-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-713\" src=\"http:\/\/gomocool.net\/gomokulog\/wp-content\/uploads\/2015\/11\/nlog-1.png\" alt=\"nlog-1\" width=\"512\" height=\"358\" \/><\/a><\/p>\n<p>NLog\u3092NuGet\u3067\u63a2\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/p>\n<p><a href=\"http:\/\/gomocool.net\/gomokulog\/wp-content\/uploads\/2015\/11\/nlog-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-714\" src=\"http:\/\/gomocool.net\/gomokulog\/wp-content\/uploads\/2015\/11\/nlog-2.png\" alt=\"nlog-2\" width=\"1125\" height=\"654\" \/><\/a><\/p>\n<p><a href=\"http:\/\/gomocool.net\/gomokulog\/wp-content\/uploads\/2015\/11\/nlog-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-715\" src=\"http:\/\/gomocool.net\/gomokulog\/wp-content\/uploads\/2015\/11\/nlog-3.png\" alt=\"nlog-3\" width=\"500\" height=\"500\" \/><\/a><\/p>\n<p>\u53c2\u7167\u306bNLog\u304c\u3067\u308c\u3070OK\u3002<\/p>\n<p><a href=\"http:\/\/gomocool.net\/gomokulog\/wp-content\/uploads\/2015\/11\/nlog-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-716\" src=\"http:\/\/gomocool.net\/gomokulog\/wp-content\/uploads\/2015\/11\/nlog-4.png\" alt=\"nlog-4\" width=\"362\" height=\"424\" \/><\/a><\/p>\n<p>Web.config\u306b\u4ee5\u4e0b\u306e\u69d8\u306a\u611f\u3058\u3067configSections\u3078section\u30bf\u30b0\u3092\u8ffd\u52a0\u3057\u3001nlog\u30bf\u30b0\u3092\u8ffd\u8a18\u3059\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true\">&lt;configuration&gt;\r\n  &lt;configSections&gt;\r\n    &lt;section name=\"nlog\" type=\"NLog.Config.ConfigSectionHandler, NLog\" \/&gt;\r\n  &lt;\/configSections&gt;\r\n\r\n  &lt;nlog xmlns=\"http:\/\/www.nlog-project.org\/schemas\/NLog.xsd\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"&gt;\r\n    &lt;targets&gt;\r\n      &lt;target name=\"logfile\" xsi:type=\"File\" fileName=\"C:\\temp\\nlogfile.txt\" \/&gt;\r\n    &lt;\/targets&gt;\r\n    &lt;rules&gt;\r\n        &lt;logger name=\"*\" minlevel=\"Info\" writeTo=\"logfile\" \/&gt;\r\n    &lt;\/rules&gt;\r\n  &lt;\/nlog&gt;\r\n&lt;\/configuration&gt;<\/pre>\n<p>\u4f7f\u3046\u5834\u5408\u306f\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3002<\/p>\n<pre class=\"lang:c# decode:true\">\/\/using NLog; \r\n\r\nLogger logger = LogManager.GetCurrentClassLogger();\r\n\r\nlogger.Trace(\"Sample trace message\");\r\nlogger.Debug(\"Sample debug message\");\r\nlogger.Info(\"Sample informational message\");\r\nlogger.Warn(\"Sample warning message\");\r\nlogger.Error(\"Sample error message\");\r\nlogger.Fatal(\"Sample fatal error message\");\r\n\r\nlogger.Log(LogLevel.Info, \"Sample informational message\");\r\n\r\nreturn View();<\/pre>\n<p>nlog\u30bf\u30b0\u3067\u8a2d\u5b9a\u3057\u305f\u3000C:\\temp\\nlogfile.txt\u3000\u306b\u3001\u4ee5\u4e0b\u306e\u69d8\u306b\u51fa\u529b\u3055\u308c\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true \">2015-11-20 11:25:48.6147|INFO|MvcLabo.Controllers.HomeController|Sample informational message\r\n2015-11-20 11:25:48.6237|WARN|MvcLabo.Controllers.HomeController|Sample warning message\r\n2015-11-20 11:25:48.6237|ERROR|MvcLabo.Controllers.HomeController|Sample error message\r\n2015-11-20 11:25:48.6237|FATAL|MvcLabo.Controllers.HomeController|Sample fatal error message\r\n2015-11-20 11:25:48.6237|INFO|MvcLabo.Controllers.HomeController|Sample informational message\r\n<\/pre>\n<p>\u4ee5\u4e0a\u3002<\/p>\n<p>\u8d85\u7c21\u5358\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>Tips<\/h3>\n<p>\u25cb\u5404.NetFramework\u3054\u3068\u306b\u30d0\u30fc\u30b8\u30e7\u30f3\u304c\u3042\u308b\u3088\u3046\u306a\u306e\u3067\u3001\u9014\u4e2d\u3067.NetFramework\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u5909\u3048\u305f\u308a\u3059\u308b\u5834\u5408\u306f\u3001\u518d\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u307b\u3046\u304c\u7121\u96e3\u3002<\/p>\n<p>\u25cb\u304b\u306a\u308a\u7c21\u5358\u306b\u66f8\u3044\u305f\u3051\u3069\u3001\u30ed\u30b0\u30ed\u30fc\u30c6\u30fc\u30c8\u3001\u30ec\u30d9\u30eb\u306b\u3088\u308b\u5207\u308a\u5206\u3051\u3001\u8907\u6570\u30ed\u30b0\u3078\u306e\u5410\u304d\u51fa\u3057\u3001\u30d5\u30a1\u30a4\u30eb\u3067\u306a\u304f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u30ed\u30b0\u5410\u304d\u51fa\u3057\u306a\u3069\u3001\u4f7f\u3044\u5207\u308c\u3066\u306a\u3044\u6a5f\u80fd\u304c\u305f\u304f\u3055\u3093\u3042\u308b\u3002<\/p>\n<p>\u25cb\u3082\u3061\u308d\u3093\u3001Web.config\u3067\u306a\u304f\u3001\u30c7\u30b9\u30af\u30c8\u30c3\u30d7\u30a2\u30d7\u30ea\u7b49\u306eapp.config\u3067\u3082\u540c\u3058\u3088\u3046\u306b\u4f7f\u3048\u308b\u3002<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>VisualStudio \u3067\u30ed\u30b0\u51fa\u529b\u3092\u3059\u308b\u306a\u3089\u3001NLog\u304c\u30aa\u30b9\u30b9\u30e1\u3002 VisualStudio2013\u3001VisualStudio2015\u306a\u3089\u3001NuGet\u3067\u7c21\u5358\u306b\u5c0e\u5165\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u300c\u3081\u3093\u3069\u304f\u3055\u3044\u3053\u3068\u899a\u3048\u305a\u306b\u3001&hellip;  <a href=\"https:\/\/gomokulog.gomocool.net\/?p=708\" class=\"more-link\">more <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66,20,43,69],"tags":[],"class_list":["post-708","post","type-post","status-publish","format-standard","hentry","category-dot-net","category-csharp","category-visualbasic-net","category-69"],"_links":{"self":[{"href":"https:\/\/gomokulog.gomocool.net\/index.php?rest_route=\/wp\/v2\/posts\/708","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gomokulog.gomocool.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gomokulog.gomocool.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gomokulog.gomocool.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gomokulog.gomocool.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=708"}],"version-history":[{"count":4,"href":"https:\/\/gomokulog.gomocool.net\/index.php?rest_route=\/wp\/v2\/posts\/708\/revisions"}],"predecessor-version":[{"id":719,"href":"https:\/\/gomokulog.gomocool.net\/index.php?rest_route=\/wp\/v2\/posts\/708\/revisions\/719"}],"wp:attachment":[{"href":"https:\/\/gomokulog.gomocool.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=708"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gomokulog.gomocool.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=708"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gomokulog.gomocool.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=708"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}