{"id":221,"date":"2015-05-29T16:06:31","date_gmt":"2015-05-29T07:06:31","guid":{"rendered":"http:\/\/sonic.blue\/it\/?p=221"},"modified":"2016-08-29T15:09:10","modified_gmt":"2016-08-29T06:09:10","slug":"%e3%82%b3%e3%83%b3%e3%82%bd%e3%83%bc%e3%83%ab%e7%94%bb%e9%9d%a2%e3%81%a8%e3%83%ad%e3%82%b0%e3%83%95%e3%82%a1%e3%82%a4%e3%83%ab%e3%81%ab%e5%90%8c%e6%99%82%e3%81%ab%e6%9b%b8%e3%81%8d%e8%be%bc%e3%82%80","status":"publish","type":"post","link":"http:\/\/sonic.blue\/it\/221","title":{"rendered":"\u30b3\u30f3\u30bd\u30fc\u30eb\u30a2\u30d7\u30ea\u3067\u753b\u9762\u3068\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306b\u540c\u6642\u306b\u66f8\u304d\u8fbc\u3080\u65b9\u6cd5"},"content":{"rendered":"<p>C#\u3084VB.NET\u3067\u4f5c\u3063\u305f\u30b3\u30f3\u30bd\u30fc\u30eb\u30a2\u30d7\u30ea\u3067\u3001\u30b3\u30f3\u30bd\u30fc\u30eb\u3078\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092Console.SetOut\u3092\u4f7f\u3063\u3066\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306b\u7c21\u5358\u306b\u66f8\u304d\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u305d\u3046\u3059\u308b\u3068\u753b\u9762\u306b\u306f\u4f55\u3082\u8868\u793a\u3055\u308c\u305a\u3001\u4f55\u304b\u3042\u3063\u305f\u6642\u306b\u6bce\u56de\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3092\u78ba\u8a8d\u3057\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093\u3002<\/p>\n<p>\u305d\u3093\u306a\u6642\u306f\u4ee5\u4e0b\u306e\u65b9\u6cd5\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u753b\u9762\u3068\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u4e21\u65b9\u306b\u66f8\u304d\u51fa\u3059\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<br \/>\n\uff08\u203b2015\/8\/10 VB.NET\u306e\u30b3\u30fc\u30c9\u3082\u8ffd\u8a18\u3057\u307e\u3057\u305f\u3002\uff09<\/p>\n<h2>\u5ba3\u8a00<\/h2>\n<p>C#\u306e\u30b3\u30fc\u30c9<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nusing System;\r\nusing System.IO;\r\n\r\n\u00a0 \u00a0 private static StreamWriter sw, standard;\/\/\u30ed\u30b0\u8a18\u9332\u7528\r\n\u00a0\u00a0\u00a0 \/\/Console\u753b\u9762\u3068\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u540c\u6642\u51fa\u529b\u7528\r\n\u00a0\u00a0\u00a0 private static void ConsoleLog(StreamWriter sw, string msg)\r\n\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3078\u51fa\u529b\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Console.SetOut(sw);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Console.WriteLine(msg);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 sw.Flush();\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/Console\u753b\u9762\u3078\u51fa\u529b\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Console.SetOut(standard);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Console.WriteLine(msg);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 standard.Flush();\r\n\u00a0\u00a0\u00a0 }\r\n<\/pre>\n<p>VB.NET\u306e\u30b3\u30fc\u30c9<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\nImports System\r\nImports System.IO\r\n\r\n    Private Shared sw As StreamWriter, standard As StreamWriter\r\n    '\u30ed\u30b0\u8a18\u9332\u7528\r\n    'Console\u753b\u9762\u3068\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3078\u306e\u540c\u6642\u51fa\u529b\u7528\r\n    Private Shared Sub ConsoleLog(sw As StreamWriter, msg As String)\r\n        '\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3078\u51fa\u529b\r\n        Console.SetOut(sw)\r\n        Console.WriteLine(msg)\r\n        sw.Flush()\r\n\r\n        'Console\u753b\u9762\u3078\u51fa\u529b\r\n        Console.SetOut(standard)\r\n        Console.WriteLine(msg)\r\n        standard.Flush()\r\n    End Sub\r\n<\/pre>\n<h2>\u521d\u671f\u8a2d\u5b9a\uff08\u4f7f\u3046\u524d\u306b\u5ba3\u8a00\u3059\u308b\uff09<\/h2>\n<p>C#\u306e\u30b3\u30fc\u30c9<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n    \/\/\u30ed\u30b0\u51fa\u529b\u8a2d\u5b9a\r\n    sw = new StreamWriter(DateTime.Now.ToString(&quot;yyyyMMdd&quot;) + &quot;.log&quot;, true, System.Text.Encoding.GetEncoding(&quot;Shift_JIS&quot;));\r\n    standard = new StreamWriter(Console.OpenStandardOutput(), System.Text.Encoding.GetEncoding(&quot;Shift_JIS&quot;));\r\n<\/pre>\n<p>VB.NET\u306e\u30b3\u30fc\u30c9<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n    '\u30ed\u30b0\u51fa\u529b\u8a2d\u5b9a\r\n    sw = New StreamWriter(DateTime.Now.ToString(&quot;yyyyMMdd&quot;) &amp; &quot;.log&quot;, True, System.Text.Encoding.GetEncoding(&quot;Shift_JIS&quot;))\r\n    standard = New StreamWriter(Console.OpenStandardOutput(), System.Text.Encoding.GetEncoding(&quot;Shift_JIS&quot;))\r\n<\/pre>\n<h2>\u4f7f\u3044\u65b9\u30b5\u30f3\u30d7\u30eb<\/h2>\n<p>\u4f7f\u3044\u305f\u3044\u5834\u6240\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3092\u8ffd\u52a0\u3057\u3066\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>C#\u306e\u30b3\u30fc\u30c9<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\u00a0 \u00a0 try\r\n\u00a0\u00a0\u00a0 {\r\n        ConsoleLog(sw, &quot;\u958b\u59cb:&quot; + DateTime.Now.ToString());\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/\u4f55\u304b\u306e\u51e6\u7406\r\n        ConsoleLog(sw, &quot;\u7d42\u4e86: &quot; + DateTime.Now.ToString());\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 catch (Exception ex)\r\n\u00a0\u00a0\u00a0 {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ConsoleLog(sw, &quot;Error: &quot; + ex.Message);\r\n\u00a0\u00a0\u00a0 }\r\n<\/pre>\n<p>VB.NET\u306e\u30b3\u30fc\u30c9<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n    Try\r\n        ConsoleLog(sw, &quot;\u958b\u59cb:&quot; &amp; DateTime.Now.ToString())\r\n        '\u4f55\u304b\u306e\u51e6\u7406\r\n        ConsoleLog(sw, &quot;\u7d42\u4e86: &quot; &amp; DateTime.Now.ToString())\r\n    Catch ex As Exception\r\n        ConsoleLog(sw, &quot;Error: &quot; &amp; ex.Message)\r\n    End Try\r\n<\/pre>\n<p>\u3053\u306e\u4ee3\u511f\u3068\u3057\u3066\u3001Format\u5f62\u5f0f\u3092\u5229\u7528\u3057\u305f\u51fa\u529b\u306f\u3067\u304d\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u5c11\u3057\u3060\u3051\u9762\u5012\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u6c17\u306b\u306a\u308b\u65b9\u306f\u30aa\u30fc\u30d0\u30fc\u30ed\u30fc\u30c9\u3067\u9811\u5f35\u3063\u3066\u4f5c\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>Search Index:<br \/>\nHow to do logging and Command Output in console application.<br \/>\nhow to Console.SetOut and Console.WriteLine dual use.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C#\u3084VB.NET\u3067\u4f5c\u3063\u305f\u30b3\u30f3\u30bd\u30fc\u30eb\u30a2\u30d7\u30ea\u3067\u3001\u30b3\u30f3\u30bd\u30fc\u30eb\u3078\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092Console.SetOut\u3092\u4f7f\u3063\u3066\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306b\u7c21\u5358\u306b\u66f8\u304d\u8fbc\u3080\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001\u305d\u3046\u3059\u308b\u3068\u753b\u9762\u306b\u306f\u4f55\u3082\u8868\u793a\u3055\u308c\u305a\u3001\u4f55\u304b\u3042\u3063\u305f\u6642\u306b\u6bce\u56de\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u3092 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,4,2],"tags":[],"class_list":["post-221","post","type-post","status-publish","format-standard","hentry","category-csharp","category-vb","category-program"],"_links":{"self":[{"href":"http:\/\/sonic.blue\/it\/wp-json\/wp\/v2\/posts\/221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/sonic.blue\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/sonic.blue\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/sonic.blue\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/sonic.blue\/it\/wp-json\/wp\/v2\/comments?post=221"}],"version-history":[{"count":31,"href":"http:\/\/sonic.blue\/it\/wp-json\/wp\/v2\/posts\/221\/revisions"}],"predecessor-version":[{"id":1036,"href":"http:\/\/sonic.blue\/it\/wp-json\/wp\/v2\/posts\/221\/revisions\/1036"}],"wp:attachment":[{"href":"http:\/\/sonic.blue\/it\/wp-json\/wp\/v2\/media?parent=221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/sonic.blue\/it\/wp-json\/wp\/v2\/categories?post=221"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/sonic.blue\/it\/wp-json\/wp\/v2\/tags?post=221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}