小编给大家分享一下VB.NET怎么写Log方法,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!
最近在项目中有用到VB.NET写Log方法的功能.具体代码如下:
Code
Public Sub WriteLog()Sub
WriteLog(ByVal Msg As String)
Dim varAppPath As String
varAppPath = System.AppDomain.
CurrentDomain.SetupInformation.
ApplicationBase + "log"
System.IO.Directory.CreateDirectory
(varAppPath)
Dim head As String
head = System.DateTime.Now.Hour.
ToString() + ":" + System.DateTime.
Now.Minute.ToString()
headhead = head + ":" + System.DateTime.
Now.Second.ToString() + ":" +
System.DateTime.Now.Millisecond.ToString()
Msg = head + System.Environment.
NewLine + Msg + System.Environment.NewLine
Dim strDate As String
strDate = System.DateTime.Now.
ToString("yyyyMMdd")
Dim strFile As String
strFile = varAppPath + "\" +
strDate + ".log"
Dim SW As System.IO.StreamWriter
SW = New System.IO.StreamWriter
(strFile, True)
SW.WriteLine(Msg)
SW.Flush()
SW.Close()
End Sub
以上是“VB.NET怎么写Log方法”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。