« Previous Next »

Thread: Extracting more than one line from a textfile

Last post 05-03-2007 4:09 AM by LogParser User : andru_nl. 4 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (5 items)

Sort Posts:

  • 07-24-2006, 4:09 AM

    Extracting more than one line from a textfile

    Reading the manual provided with the installation routine I wonder how to parse a text file.
    I managed to search for a specific string and get the whole line where this string occured.
    Now the question is, if the wanted line is not that one but the following two or three lines.
    So, is it possible to tell logparser to look for a specific string within a text file and output that line (or that line +n) plus the next n lines?

    Regards,

    Matthias Ruch
  • 07-24-2006, 9:59 AM In reply to

    RE: Extracting more than one line from a textfile

    Sorry, multi-line records are not supported by LogParser.
  • 07-25-2006, 8:57 AM In reply to

    RE: Extracting more than one line from a textfile

    Is that true...
    I thought that such a powerful tool with the capability of understanding lots of different logfile formats and various output options was also capable of the basic functions of a parser software.

    So, from my understanding, logparser can only be used to parse files that have one of the known formats.
    Is there a plan to implement basic parsing functionality in the near future?

    Best regards,
    Matthias Ruch
  • 07-25-2006, 10:44 AM In reply to

    RE: Extracting more than one line from a textfile

    Well, LP does provide a COM API that you could take advantage of to write your own multi-line parser. Even then, I think it would still be rather difficult to write a custom input format that would be able to take an offset of lines from a matched term.

    At its heart, LP is a relational or flat file parser. Multi-line formats don't fit into that scheme. There are plenty of scripting platforms that are much better suited to working out a quick solution to the type of problem you describe. It is almost a one-liner in any of the currently popular three (Perl/Python/Ruby).
  • 05-03-2007, 4:09 AM In reply to

    RE: Extracting more than one line from a textfile

    Eventually, any log files contain the lines that are related to each other.

    Every log parsing task i had so far, I encountered the need to "sneak peek" couple of lines ahead, treat 2 or more lines as a single event, process a line1 if a line2 was found before, otherwise ignore, etc.

    I implemented it so far using the state machines, but that is a complicated and not optimal solution.

    You refer to "better suited platforms". Any chance that you tried to solve the same problems before me? Are there a generic patterns/algorithms for that?

Page 1 of 1 (5 items)
Microsoft Communities