Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Anyone got any idea on processing and displaying the content of a very large text file?

Currently, my attempt fails when the file size is in tens of megabytes. (StringBuilder constructor dies with Out of Memory Exception.)

I need to:
*Display the full log
*Display the full log without lines containing certain key words
*Display only the lines containing certain key words. These must be listed per key word
*Display or hide supplementary information at will
*Track a key word line back to the full log with ease.

=========================================
Here is the longer version of the story:
I've got a 3rd party (i.e. of which I have no control over the spec) software that spits out endless amounts of log, and I need to write a tool to analyze it.

The log is a simple text file delimited by "\r\n".

A common size is around 10MB.

At this size, notepad can't cope, but there are other viewers that can display the content, e.g. wordpad.

However, displaying is one thing, making sense of it is quite another.

So I made a tool that pulls out a line of log a time according to a set of predetermined key words and lists them in list boxes per key word.

So one list box lists all the "Open file" related log, another lists a "Start analysis" related log and so on.

Also, some commands take long input strings. For example, "Start analysis" takes an XML input of how to perform the analysis. For these logs, the details can be hidden or shown as instructed by the user.

Each item in the list boxes can be traced back to the full log which is displayed in a rich text box with double click.

It's exactly what I needed. I can cross reference the key words with the full log and view just the information I need at any given time...

except...

it blows up when the file size is in the tens of megabytes.

The biggest file I have to hand is over 200MB.

How can I extend my little log analyzer to cope with much bigger log files?
Is there a better way of implementing what I mean to do?

Any suggestions greatly appreciated.
Posted

1 solution

Can you think of an alternative: instead of you home-baked logging, you can log in System event log (viewable via the applet: eventvwr.msc /s). Use System.Diagnostics.EventLog, http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx[^].

Leave those problems to the OS!

See also some practical advice in my past solutions:
How to create event log under a folder[^],
MsBuild OutPut to the TextBox on the fly in Windows Application[^].

—SA
 
Share this answer
 
Comments
PaulowniaK 23-Nov-11 19:40pm    
Thanks, but maybe I didn't explain well enough. The biggest problem is that what's writing the log is a 3rd party software which I have no control over its internal doings. I'm stuck with the reality that I get 10s and 100s of MB of log.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900