How to Create log file with time Set
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: How to Create log file with time Set

  1. #1
    Join Date
    Jan 2014
    Posts
    5

    Talking How to Create log file with time Set

    Hello guys =)
    how do we create log file with time set like this picture?
    Name:  log.png
Views: 106
Size:  4.8 KB

    here is my timerlog code
    Code:
     Private Sub logtimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles logtimer.Tick
    
            Dim textline(100000) As String
            Dim log_ctr As Integer
            Dim last_log As Integer
    
    
            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress30
            logs.Text = ""
    
            'WARNING
            'the file log.txt must exits or this will give an error, openvpn's configuration files must not disable logging.
            Dim a As String = "Time:" + " " + Format(TimeOfDay)
            FileOpen(1, Application.StartupPath & "\data\log.txt", OpenMode.Input, , OpenShare.LockRead)
            Do Until EOF(1)
    
                textline(log_ctr) = LineInput(1)
                log_ctr = log_ctr + 1
                If last_log <> log_ctr Then
    
                    For n = last_log To log_ctr - 1
    
                        If InStrRev(textline(n), "OreVPN") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress40
                            logs.SelectedText = "Connecting to the Network......." & vbCrLf
    
                        ElseIf InStrRev(textline(n), "this configuration to call") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress50
                            logs.SelectedText = "Bypassing ISP Sever Firewall......" & vbCrLf & "Accessing Server....please wait" & vbCrLf
    
                        ElseIf InStrRev(textline(n), "Peer Connection Initiated with 0.0.0.0:0") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress60
                            logs.SelectedText = "Hacking Server System...." & vbCrLf
    
                        ElseIf InStrRev(textline(n), "TAP-WIN32 device") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress70
                            logs.SelectedText = "Injecting Server with code OreVX01...." & vbCrLf
    
                        ElseIf InStrRev(textline(n), "NETSH: C:\WINDOWS\system32\netsh.exe interface ip set address {") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress80
                            logs.SelectedText = "Warning!! You Have been detected!!" & vbCrLf & "Your IP have being save & send to the police!!" & vbCrLf
    
                        ElseIf InStrRev(textline(n), "Successful ARP Flush on interface") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress90
                            logs.SelectedText = "Successful ARP Flush" & vbCrLf
    
                        ElseIf InStrRev(textline(n), "Initialization Sequence Completed") > 0 Then
                            'CONNECT SUCCESSFUL
                            'set the timer to a 30 sec interval to minimize file access but not too long to prevent a timeout
                            log_Timer.Interval = 30000
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress100
                            logs.SelectedText = "You're Connected to our System, Enjoy Your Browsing" & vbCrLf & "--OreVPN Team--"
                            status_lbl.Text = "Connected"
                            status_lbl.ForeColor = Color.Lime
                            title_lbl.Text = "OreVPN v" & myver & ""
                            title_lbl.ForeColor = Color.Lime
                            'ENABLE STATISTICS
                            'starts timer for bandwidth calculations and display
                            TimerBandwidth.Enabled = True
                            'starts timer for ping latency and display
                            TimerLatency.Enabled = True
                            GroupBox1.Visible = True
                            PictureBoxProgressbar.Visible = False
                            konekbtn.Enabled = False
                            dkonekbtn.Enabled = True
    
                            '---Check IP Address---'
    
                            Dim req As HttpWebRequest = WebRequest.Create("http://myip.dnsomatic.com/")
                            Dim res As HttpWebResponse = req.GetResponse()
                            Dim str As Stream = res.GetResponseStream()
                            Dim sr As StreamReader = New StreamReader(str)
                            IP.Text = "--> Your IP: " & sr.ReadToEnd
    
                            update_timer.Enabled = True
    
    
                        ElseIf InStrRev(textline(n), "Inactivity timeout (--ping-restart), restarting") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress50
                            logs.SelectedText = TimeOfDay & "Connection Timeout"
                            status_lbl.Text = "Disconnected"
                            disconnectroutine()
    
                        ElseIf InStrRev(textline(n), "Exiting") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress50
                            logs.SelectedText = TimeOfDay & "Connection Timeout"
                            disconnectroutine()
    
                        ElseIf InStrRev(textline(n), "AUTH: Received AUTH_FAILED control message") > 0 Then
                            disconnectroutine()
                            logs.Text = TimeOfDay & "***AUTH FAILED***" & vbCrLf & "Please Check Your Username and Password" & vbCrLf & vbCrLf & "Contact your reseller for help" & vbCrLf & vbCrLf & "======OreVPN Team======"
                            MessageBox.Show("Please Check Your Username & Password", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                        End If
    
                    Next
    
                    last_log = log_ctr
    
                End If
            Loop
            FileClose(1)
    
    
        End Sub

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,951

    Re: How to Create log file with time Set

    You don't open the file INSIDE of the timer tick event. There are options to write to the system log, and then use it from there.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jan 2014
    Posts
    5

    Re: How to Create log file with time Set

    Thank dglienna,
    its really kind if you can show me how to do it

  4. #4
    Join Date
    Jan 2014
    Posts
    1

    Re: How to Create log file with time Set

    Quote Originally Posted by IRduranni View Post
    Hello guys =)
    how do we create log file with time set like this picture?
    Name:  log.png
Views: 106
Size:  4.8 KB

    here is my timerlog code
    Code:
     Private Sub logtimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles logtimer.Tick
    
            Dim textline(100000) As String
            Dim log_ctr As Integer
            Dim last_log As Integer
    
    
            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress30
            logs.Text = ""
    
            'WARNING
            'the file log.txt must exits or this will give an error, openvpn's configuration files must not disable logging.
            Dim a As String = "Time:" + " " + Format(TimeOfDay)
            FileOpen(1, Application.StartupPath & "\data\log.txt", OpenMode.Input, , OpenShare.LockRead)
            Do Until EOF(1)
    
                textline(log_ctr) = LineInput(1)
                log_ctr = log_ctr + 1
                If last_log <> log_ctr Then
    
                    For n = last_log To log_ctr - 1
    
                        If InStrRev(textline(n), "OreVPN") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress40
                            logs.SelectedText = "Connecting to the Network......." & vbCrLf
    
                        ElseIf InStrRev(textline(n), "this configuration to call") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress50
                            logs.SelectedText = "Bypassing ISP Sever Firewall......" & vbCrLf & "Accessing Server....please wait" & vbCrLf
    
                        ElseIf InStrRev(textline(n), "Peer Connection Initiated with 0.0.0.0:0") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress60
                            logs.SelectedText = "Hacking Server System...." & vbCrLf
    
                        ElseIf InStrRev(textline(n), "TAP-WIN32 device") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress70
                            logs.SelectedText = "Injecting Server with code OreVX01...." & vbCrLf
    
                        ElseIf InStrRev(textline(n), "NETSH: C:\WINDOWS\system32\netsh.exe interface ip set address {") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress80
                            logs.SelectedText = "Warning!! You Have been detected!!" & vbCrLf & "Your IP have being save & send to the police!!" & vbCrLf
    
                        ElseIf InStrRev(textline(n), "Successful ARP Flush on interface") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress90
                            logs.SelectedText = "Successful ARP Flush" & vbCrLf
    
                        ElseIf InStrRev(textline(n), "Initialization Sequence Completed") > 0 Then
                            'CONNECT SUCCESSFUL
                            'set the timer to a 30 sec interval to minimize file access but not too long to prevent a timeout
                            log_Timer.Interval = 30000
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress100
                            logs.SelectedText = "You're Connected to our System, Enjoy Your Browsing" & vbCrLf & "--OreVPN Team--"
                            status_lbl.Text = "Connected"
                            status_lbl.ForeColor = Color.Lime
                            title_lbl.Text = "OreVPN v" & myver & ""
                            title_lbl.ForeColor = Color.Lime
                            'ENABLE STATISTICS
                            'starts timer for bandwidth calculations and display
                            TimerBandwidth.Enabled = True
                            'starts timer for ping latency and display
                            TimerLatency.Enabled = True
                            GroupBox1.Visible = True
                            PictureBoxProgressbar.Visible = False
                            konekbtn.Enabled = False
                            dkonekbtn.Enabled = True
    
                            '---Check IP Address---'
    
                            Dim req As HttpWebRequest = WebRequest.Create("http://myip.dnsomatic.com/")
                            Dim res As HttpWebResponse = req.GetResponse()
                            Dim str As Stream = res.GetResponseStream()
                            Dim sr As StreamReader = New StreamReader(str)
                            IP.Text = "--> Your IP: " & sr.ReadToEnd
    
                            update_timer.Enabled = True
    
    
                        ElseIf InStrRev(textline(n), "Inactivity timeout (--ping-restart), restarting") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress50
                            logs.SelectedText = TimeOfDay & "Connection Timeout"
                            status_lbl.Text = "Disconnected"
                            disconnectroutine()
    
                        ElseIf InStrRev(textline(n), "Exiting") > 0 Then
                            PictureBoxProgressbar.BackgroundImage = OreVPN.My.Resources.progress50
                            logs.SelectedText = TimeOfDay & "Connection Timeout"
                            disconnectroutine()
    
                        ElseIf InStrRev(textline(n), "AUTH: Received AUTH_FAILED control message") > 0 Then
                            disconnectroutine()
                            logs.Text = TimeOfDay & "***AUTH FAILED***" & vbCrLf & "Please Check Your Username and Password" & vbCrLf & vbCrLf & "Contact your reseller for help" & vbCrLf & vbCrLf & "======OreVPN Team======"
                            MessageBox.Show("Please Check Your Username & Password", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                        End If
    
                    Next
    
                    last_log = log_ctr
    
                End If
            Loop
            FileClose(1)
    
    
        End Sub
    Hi,

    You have 2 options 1 is direct talk to a programmer or hire a ASP.NET Programmers. Because they have total solutions. May be use given link for hire a programmer http://www.xicom.biz/offerings/hire-...t-programmers/

    And http://www.iis.net/configreference/s...faults/logfile this link is useful for problem solution.

    Thanks

  5. #5
    Join Date
    Jan 2014
    Posts
    5

    Re: How to Create log file with time Set

    Thank Guys,
    Actually i have already create the log system, its just is it possible to put time in front of it?
    p/s : the source code above it the code to create the log like that...its just how can we put time in front of it?

    here is my current software log
    Name:  log 2.png
Views: 75
Size:  4.2 KB
    here is what i want its to be
    Name:  log.png
Views: 74
Size:  4.8 KB

  6. #6
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,951

    Re: How to Create log file with time Set

    Load the TIME into a variable before this line: or better yet, if you want calculate it each iteration, but that might slow things down
    Code:
    For n = last_log To log_ctr - 1
    Debug.Print myTime;
    And then You could use the ; character at the end of a line, to suppress linefeed
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Jan 2014
    Posts
    5

    Re: How to Create log file with time Set

    its not working sirs,
    could you kindly show the full code?

  8. #8
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,951

    Re: How to Create log file with time Set

    Assign a variable, then use it:

    Code:
    logs.SelectedText =  myTime & "  Connecting to the Network......." & vbCrLf
    Also, I'd like to know more about what you are doing to that server and the ARP...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center