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