Link to home
Create AccountLog in
Avatar of R555B
R555B

asked on

write to log file columns in vb

Hi All,

Having trouble writing to a logfile and getting the data to dispaly where I want.

What I want to acheive is:
 User generated image
But what Im getting is:
User generated image
....So my code isnt writing ot all the columns.
            Dim str As String = "<![LOG[" & message & "]LOG]!><time=""" & Now.ToLongTimeString & """" & " date=""" & Now.ToShortDateString & """ component=""" & component.ToString & """" & " type=""1""" & " Thread=""" & t & """" & ">"
            File.AppendAllText(logfile, str & vbCrLf)

Open in new window


...What Am I missing here ?
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Put a breakpoint on this line:
File.AppendAllText(logfile, str & vbCrLf)
and look at the contents of str.
Avatar of R555B
R555B

ASKER

I've stepped it through the debugger a couple of times...This is the first line that comes out:

"<![LOG[Server Started]LOG]!><time="18:21:32" date="25/02/2015" component="(Main:)" type="1" Thread="8">"

...As far as I can see all the quotes and brackets line up.
That makes me think your posted code is fine - the problem is likely by the code you use to fill the grid display.
Avatar of R555B

ASKER

Managed to find some raw data from one of the existing log files on my system. I think maybe the columns are expecting the data to be in a certain format before it will display - As far as I can tell though there is no obvious way to determine what that format is.

I've now managed to get component and date time to appear properly using the following syntax:

Dim d As String = Now.Month & "-" & Now.Day & "-" & Now.Year
Dim str As String = "<![LOG[" & message & "]LOG]!><time=""" & Now.ToLongTimeString & "." & Now.Millisecond & "-60" & """" & " date=""" & d & """ component=""" & component.ToString & """" & " type=""1""" & " Thread=""" & t & """" & """ File=Me

Open in new window


Thread still isnt appearing properly but I think I can probably live with that
>>I think maybe the columns are expecting the data to be in a certain format before it will display - As far as I can tell though there is no obvious way to determine what that format is.

Is this some third party tool or something you don't have the code / documentation for?
Avatar of R555B

ASKER

No - its just appending the text to a standard .log file. Just no way to know what it expects.
Could you provide your method to read the data from the text file and display it in the grid?

-saige-
>>No - its just appending the text to a standard .log file. Just no way to know what it expects.

To repeat myself:
Is this some third party tool or something you don't have the code / documentation for?
By that I meant the viewer that you are using to see the log file output.
Avatar of R555B

ASKER

viewer is cmtrace.exe
Avatar of R555B

ASKER

I've requested that this question be closed as follows:

Accepted answer: 0 points for R555B's comment #a40631371

for the following reason:

Persevered and found the answer
Please post just how you solved this or request a delete.
ASKER CERTIFIED SOLUTION
Avatar of R555B
R555B

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account