• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 58
  • Last Modified:

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:
 Untitled.png
But what Im getting is:
srv.png
....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 ?
0
R555B
Asked:
R555B
  • 6
  • 5
1 Solution
 
AndyAinscowFreelance programmer / ConsultantCommented:
Put a breakpoint on this line:
File.AppendAllText(logfile, str & vbCrLf)
and look at the contents of str.
0
 
R555BAuthor Commented:
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.
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
That makes me think your posted code is fine - the problem is likely by the code you use to fill the grid display.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
R555BAuthor Commented:
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
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
>>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?
0
 
R555BAuthor Commented:
No - its just appending the text to a standard .log file. Just no way to know what it expects.
0
 
it_saigeDeveloperCommented:
Could you provide your method to read the data from the text file and display it in the grid?

-saige-
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
>>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.
0
 
R555BAuthor Commented:
viewer is cmtrace.exe
0
 
R555BAuthor Commented:
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
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
Please post just how you solved this or request a delete.
0
 
R555BAuthor Commented:
 Dim str As String = "<![LOG[++ " & message & "]LOG]!><time=""" & Now.ToLongTimeString & "." & Now.Millisecond & "-60" & """" & " date=""" & d & """ component=""" & component.ToString & """" & " type=""1" & """ Thread=""" & t & """ Severity=""" & sev & """ File=""Me"">"
            File.AppendAllText(logfile, str & vbCrLf)

Open in new window


Time had to be in a specific format
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now