Log Writing Method in VB. NET

Source: Internet
Author: User

Recently, the log writing function has been used in the project. It is written using VB. NET as follows:

 

Code
1 Public   Sub writelog () Sub Writelog ( Byval MSG As   String )
2
3 Dim Varapppath As   String
4 Varapppath = System. appdomain. currentdomain. setupinformation. applicationbase +   " Log "
5 System. Io. Directory. createdirectory (varapppath)
6
7 Dim Head As   String
8 Head = System. datetime. Now. Hour. tostring () +   " : "   + System. datetime. Now. Minute. tostring ()
9 Head = Head +   " : "   + System. datetime. Now. Second. tostring () +   " : "   + System. datetime. Now. millisecond. tostring ()
10 MSG = Head + System. environment. newline + MSG + System. environment. newline
11
12 Dim Strdate As   String
13 Strdate = System. datetime. Now. tostring ( " Yyyymmdd " )
14 Dim Strfile As   String
15 Strfile = Varapppath +   " \ "   + Strdate +   " . Log "
16 Dim SW As System. Io. streamwriter
17 SW =   New System. Io. streamwriter (strfile, True )
18
19 Sw. writeline (MSG)
20 Sw. Flush ()
21 Sw. Close ()
22
23 End sub
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.