{"id":941,"date":"2011-02-02T14:58:04","date_gmt":"2011-02-02T05:58:04","guid":{"rendered":"http:\/\/www.lancard.com\/blog\/?p=941"},"modified":"2025-03-12T11:31:40","modified_gmt":"2025-03-12T02:31:40","slug":"vb-net%e3%81%aemy-application-log%e3%82%92%e3%83%a9%e3%83%83%e3%83%94%e3%83%b3%e3%82%b0%e3%81%97%e3%81%9f%e3%82%af%e3%83%a9%e3%82%b9%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/www.lancard.com\/blog\/2011\/02\/02\/vb-net%e3%81%aemy-application-log%e3%82%92%e3%83%a9%e3%83%83%e3%83%94%e3%83%b3%e3%82%b0%e3%81%97%e3%81%9f%e3%82%af%e3%83%a9%e3%82%b9%e4%bd%9c%e3%81%a3%e3%81%a6%e3%81%bf%e3%81%9f\/","title":{"rendered":"VB.NET\u306eMy.Application.Log\u3092\u30e9\u30c3\u30d4\u30f3\u30b0\u3057\u305f\u30af\u30e9\u30b9\u4f5c\u3063\u3066\u307f\u305f"},"content":{"rendered":"<p>\u73fe\u5728\u9032\u3081\u3066\u3044\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306e\u30ed\u30ae\u30f3\u30b0\u306b\u306fmiyazaki\u3055\u3093\u306b\u8abf\u3079\u3066\u3082\u3089\u3063\u305fMy.Application.Log\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u304c\u3001\u305d\u306e\u307e\u307e\u3060\u3068\u3061\u3087\u3044\u3068\u8f9b\u304b\u3063\u305f\u306e\u3067\u30e9\u30c3\u30d4\u30f3\u30b0\u3057\u3066\u30af\u30e9\u30b9\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre lang=\"vbnet\" line=\"1\">\nPublic Class Log\n    Public Shared Sub Write(\n        ByVal message As String,\n        ByVal traceEventType As String,\n        Optional ByVal isShowMsgBox As Boolean = False\n    )\n        Dim severity As System.Diagnostics.TraceEventType =\n            System.Enum.Parse(GetType(System.Diagnostics.TraceEventType), traceEventType)\n\n        My.Application.Log.WriteEntry(My.Computer.Clock.LocalTime.ToString & \"> \" & message, severity)\n        My.Application.Log.TraceSource.Flush()\n        &#039;\u4e0b\u8a18\u8868\u793a\u5224\u5b9a\u306f\u4f55\u30d1\u30bf\u30fc\u30f3\u304b\u8a66\u3057\u305f\u7d50\u679c\u3067\u3059\u304c\u6b63\u3057\u3044\u304b\u306e\u78ba\u8a8d\u306f\u51fa\u6765\u3066\u3044\u307e\u305b\u3093\u3002\n        If My.Application.Log.TraceSource.Switch.Level > severity Then\n            showMsgBox(message, severity, traceEventType, isShowMsgBox)\n        End If\n    End Sub\n\n    Private Shared Sub showMsgBox(\n        ByVal message As String,\n        ByVal severity As System.Diagnostics.TraceEventType,\n        ByVal title As String,\n        Optional ByVal isShowMsgBox As Boolean = False\n    )\n        If isShowMsgBox Then\n            Dim msgBoxButtons As MsgBoxStyle\n            Select Case severity\n                Case Diagnostics.TraceEventType.Critical, Diagnostics.TraceEventType.Error\n                    msgBoxButtons = MsgBoxStyle.Critical\n                Case Diagnostics.TraceEventType.Warning\n                    msgBoxButtons = MsgBoxStyle.Exclamation\n                Case Else\n                    msgBoxButtons = MsgBoxStyle.Information\n            End Select\n            MsgBox(message, msgBoxButtons, title)\n        End If\n    End Sub\n\n    Public Shared Sub Verbose(\n        ByVal message As String,\n        Optional ByVal isShowMsgBox As Boolean = False\n    )\n        Log.Write(message, \"Verbose\", isShowMsgBox)\n    End Sub\n\n    Public Shared Sub Info(\n        ByVal message As String,\n        Optional ByVal isShowMsgBox As Boolean = False\n    )\n        Log.Write(message, \"Information\", isShowMsgBox)\n    End Sub\n\n    Public Shared Sub Warn(\n        ByVal message As String,\n        Optional ByVal isShowMsgBox As Boolean = False\n    )\n        Log.Write(message, \"Warning\", isShowMsgBox)\n    End Sub\n\n    Public Shared Sub Err(\n        ByVal message As String,\n        Optional ByVal isShowMsgBox As Boolean = False\n    )\n        Log.Write(message, \"Error\", isShowMsgBox)\n    End Sub\n\n    Public Shared Sub Exception(\n        ByVal ex As Exception,\n        ByVal message As String,\n        Optional ByVal isShowMsgBox As Boolean = False\n    )\n        message &= System.Environment.NewLine &\n            \" [\u4f8b\u5916\u5185\u5bb9] \" & ex.Message & System.Environment.NewLine &\n            \" [\u30b9\u30bf\u30c3\u30af\u30c8\u30ec\u30fc\u30b9] \" & System.Environment.NewLine & ex.StackTrace\n        Log.Err(message, isShowMsgBox)\n    End Sub\nEnd Class\n<\/pre>\n<p>Verbose\u304clog4net\u306eDebug\u306b\u3042\u305f\u308b\u611f\u3058\u3067\u4f7f\u3048\u308b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u30e1\u30c3\u30bb\u30fc\u30b8\u30dc\u30c3\u30af\u30b9\u3092\u8868\u793a\u3057\u305f\u308a\u3082\u51fa\u6765\u307e\u3059\u3002<\/p>\n<p>My.Application.Log.\u306b\u306f\u4f8b\u5916\u7528\u306e\u30e1\u30bd\u30c3\u30c9WriteException\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u51fa\u529b\u3055\u308c\u308b\u60c5\u5831\u304c\u30a4\u30de\u30a4\u30c1\u3060\u3063\u305f\u306e\u3067\u4f7f\u308f\u306a\u3044\u3067\u5b9f\u88c5\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u307e\u3060\u3042\u307e\u308a\u4f7f\u3063\u3066\u306a\u3044\u306e\u3067\u30d0\u30b0\u3063\u3066\u305f\u308a\u3059\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<br \/>\n\u30b3\u30fc\u30c9\u3092\u4fee\u6b63\u3057\u305f\u3089\u3053\u3053\u3082\u4fee\u6b63\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3002<\/p>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F941&#038;t=VB.NET%E3%81%AEMy.Application.Log%E3%82%92%E3%83%A9%E3%83%83%E3%83%94%E3%83%B3%E3%82%B0%E3%81%97%E3%81%9F%E3%82%AF%E3%83%A9%E3%82%B9%E4%BD%9C%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F&#038;s=100&#038;p&#091;url&#093;=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F941&#038;p&#091;images&#093;&#091;0&#093;=&#038;p&#091;title&#093;=VB.NET%E3%81%AEMy.Application.Log%E3%82%92%E3%83%A9%E3%83%83%E3%83%94%E3%83%B3%E3%82%B0%E3%81%97%E3%81%9F%E3%82%AF%E3%83%A9%E3%82%B9%E4%BD%9C%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"http:\/\/twitter.com\/share?url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F941&#038;text=VB.NET%E3%81%AEMy.Application.Log%E3%82%92%E3%83%A9%E3%83%83%E3%83%94%E3%83%B3%E3%82%B0%E3%81%97%E3%81%9F%E3%82%AF%E3%83%A9%E3%82%B9%E4%BD%9C%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F941&#038;title=VB.NET%E3%81%AEMy.Application.Log%E3%82%92%E3%83%A9%E3%83%83%E3%83%94%E3%83%B3%E3%82%B0%E3%81%97%E3%81%9F%E3%82%AF%E3%83%A9%E3%82%B9%E4%BD%9C%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-tumblr nolightbox\" data-provider=\"tumblr\" target=\"_blank\" rel=\"nofollow\" title=\"Share on tumblr\" href=\"https:\/\/tumblr.com\/share?s=&#038;v=3&#038;t=VB.NET%E3%81%AEMy.Application.Log%E3%82%92%E3%83%A9%E3%83%83%E3%83%94%E3%83%B3%E3%82%B0%E3%81%97%E3%81%9F%E3%82%AF%E3%83%A9%E3%82%B9%E4%BD%9C%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F&#038;u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F941\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"tumblr\" title=\"Share on tumblr\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/tumblr.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=VB.NET%E3%81%AEMy.Application.Log%E3%82%92%E3%83%A9%E3%83%83%E3%83%94%E3%83%B3%E3%82%B0%E3%81%97%E3%81%9F%E3%82%AF%E3%83%A9%E3%82%B9%E4%BD%9C%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F&#038;body=%E3%82%B7%E3%82%A7%E3%82%A2%E3%81%99%E3%82%8B%EF%BC%9A:%20https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F941\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>\u73fe\u5728\u9032\u3081\u3066\u3044\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306e\u30ed\u30ae\u30f3\u30b0\u306b\u306fmiyazaki\u3055\u3093\u306b\u8abf\u3079\u3066\u3082\u3089\u3063\u305fMy.Application.Log\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002 \u304c\u3001\u305d\u306e\u307e\u307e\u3060\u3068\u3061\u3087\u3044\u3068\u8f9b\u304b\u3063\u305f\u306e\u3067\u30e9\u30c3\u30d4\u30f3\u30b0\u3057\u3066\u30af\u30e9\u30b9\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002 Pub [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[54],"class_list":["post-941","post","type-post","status-publish","format-standard","hentry","category-1","tag-vb"],"_links":{"self":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/comments?post=941"}],"version-history":[{"count":10,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/941\/revisions"}],"predecessor-version":[{"id":4816,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/941\/revisions\/4816"}],"wp:attachment":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/media?parent=941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/categories?post=941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/tags?post=941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}