in reply to Is PERL right for parsing logs

Can it be very easy to parse logs with perl? definitely .. will it be right for you log files? no clue -- can you show some example input (especially for your "threads")? But it sounds like you might want to parse (perlre, perlrun) the log and dump into a database (mysql, postgres, sqlite, etc) so you can easily (DBI) do all of your various group'ings/views/sorts as SQL statements. Also, depending on what the log files look like, your solution might be attained w/standard command-line tools such as cut and sort ...

Replies are listed 'Best First'.
Re^2: Is PERL right for parsing logs
by jpeery (Initiate) on Mar 22, 2006 at 13:49 UTC

    It's long, but roughly looks like this:
    I am interested in keying on "Thread_ID:XXX"

    ---------------------------------------------------

    Each entry is seperated by "----"

    20060322 Janitored by Corion: Put data in between <code>...</code> tags

    Edited by planetscape - added readmore tags

      Surely Perl is well suited for such a parsing task. But I have some questions first.

      Some of that data seems broken, i.e. inconsistently formatted. In the first two records, the

      ----------------- Browser ===> PD -----------------
      and
      ----------------- PD ===> BackEnd -----------------
      strings are on their own lines (the second line of the record); in the subsequent records, those strings are at the end of the first line of the record. I'm also suspicious of all those empty lines within each record. Perhaps you made a copy-and-paste error?

      We're building the house of the future together.