Inser Date & Time to a logfile

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Swordfish Dundee
    New Member
    • Dec 2006
    • 3

    Inser Date & Time to a logfile

    Hi Guys,

    Complete newbvie here, trying to get an answer to my problem.

    I have written small client / server applications, in which everything that the server does is recorded in a logfile using the MY.Computer.Fil esystem string.
    I can write the statement to the file and create a new liine for example.

    Server Activity - Server Started
    Client Activity
    Client Activity - User Smith has succesfully logged in
    Client Activity - User Smith has logged off
    Server Activity - Server Shutdown.

    I want to add the date and time of each event before the activity statment line

    TIA
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Originally posted by Swordfish Dundee
    Hi Guys,

    Complete newbvie here, trying to get an answer to my problem.

    I have written small client / server applications, in which everything that the server does is recorded in a logfile using the MY.Computer.Fil esystem string.
    I can write the statement to the file and create a new liine for example.

    Server Activity - Server Started
    Client Activity
    Client Activity - User Smith has succesfully logged in
    Client Activity - User Smith has logged off
    Server Activity - Server Shutdown.

    I want to add the date and time of each event before the activity statment line

    TIA
    Hi there,

    Kindly include the below code segment to begining of the activity statement, hope it helps. Good luck & Take care.

    Code:
      Now() & "..your activity statement line.."

    Comment

    • Swordfish Dundee
      New Member
      • Dec 2006
      • 3

      #3
      Sorry, for late reply, but just back from UNI. Worked a treat. Thanks

      I've only been doing VB.Net for 6 weeks and hve no real programming skills at all (I am a network man at heart!!)

      One last thing, I am atempting to output the contents of a txt file in a display box. The file when open in windows lokos like this

      01/01/01 00:00 SERVER ACTIVITY - Server Started
      01/01/01 00:00 CLIENT ACTIVITY - User SMITH has logged on
      etc
      etc

      Yet when it displays in the lsbox (named lsLog), there are no carriage returns and all the data is in one very long line.

      Code

      Private Sub btShowlog_Click (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btShowlog.Click
      Dim fileContents As String
      lsLog.Visible = True
      lsLog.Items.Cle ar()
      btcloselog.Visi ble = True
      fileContents = My.Computer.Fil eSystem.ReadAll Text(File_Path & "atmlog.txt ")
      lsLog.Items.Add (fileContents)
      End Sub

      Again any help would be greatfully appreciated
      Last edited by Swordfish Dundee; Dec 7 '06, 07:58 PM. Reason: Spelling Errors

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        You might need to check the delimiters you have on the end of each line. The likely options are:
        • Carriage Return (CR)
        • Line Feed (LF)
        • Both CR & LF

        A lot of languages/controls in the Windows world expect CRLF to delimit lines. You might need to either modify the way you write the lines to the file to produce the correct delimiter, or read it line by line to place it in your display field.

        You might also want to check whether the control in which you're displaying the text has somethig equivalent to the VB6 textbox's MultiLine property, which determines whether it can show more than one line.

        Comment

        Working...