You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by gamby <ga...@libero.it> on 2009/06/01 13:00:56 UTC

Extract log info from each output log line on the console

Hi all,

I'm developing a tool to do some auto statistics from the generated log of
an app...

I would like to be able to parse each log line generated obviously with lo4j
and extract all the info (timestamp, thread name, message and the others) in
a way that I could process separately those info.
Obviuosly I assume to know the pattern used to produce a log, knowing that
pattern, I would like to extract all the info.

For example if I know that a log file was produced using this pattern --> %d
%-5p [%t] - %m%n
Then I would like to extract from the generated log line, the timestamp, the
priority, the thread and the message, but without parsing the raw text using
string indexes for example....

And so the flow should be:
- An application produces some log
- My component read each log line generated and extract all the info, based
on log4j pattern used to produce that log

Any hints?
Thanks in advance
Gamby
-- 
View this message in context: http://www.nabble.com/Extract-log-info-from-each-output-log-line-on-the-console-tp23813238p23813238.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Extract log info from each output log line on the console

Posted by Jacob Kjome <ho...@visi.com>.
On Mon, 1 Jun 2009 08:32:38 -0400
  Douglas E Wegscheid <Do...@whirlpool.com> wrote:
> if you have a chance to change the log file layout, use the XMLLayout. 
> It's unambiguous to parse.
> 

XMLLayout is probably the most straightforward option.  Another option is the 
receiver companion's LogFilePatternReceiver, which Chainsaw2 makes use of....

http://svn.apache.org/viewvc/logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java?view=log

See also...
http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/vfs/


Jake

> parsing the other layouts can be a problem (think about the situation of 
> messages spanning multiple lines, or that have an exception trackback...)
> 
> Douglas E Wegscheid
> Lead Technical Analyst, Whirlpool Corporation
> (269)-923-5278
> 
> "A wrong note played hesitatingly is a wrong note. A wrong note played 
> with conviction is interpretation."
> 
> 
> 
> 
> 
> gamby <ga...@libero.it> 
> 06/01/2009 07:00 AM
> Please respond to
> "Log4J Users List" <lo...@logging.apache.org>
> 
> 
> To
> log4j-user@logging.apache.org
> cc
> 
> Subject
> Extract log info from each output log line on the console
> 
> 
> 
> 
> 
> 
> 
> Hi all,
> 
> I'm developing a tool to do some auto statistics from the generated log of
> an app...
> 
> I would like to be able to parse each log line generated obviously with 
> lo4j
> and extract all the info (timestamp, thread name, message and the others) 
> in
> a way that I could process separately those info.
> Obviuosly I assume to know the pattern used to produce a log, knowing that
> pattern, I would like to extract all the info.
> 
>For example if I know that a log file was produced using this pattern --> 
> %d
> %-5p [%t] - %m%n
> Then I would like to extract from the generated log line, the timestamp, 
> the
> priority, the thread and the message, but without parsing the raw text 
> using
> string indexes for example....
> 
> And so the flow should be:
> - An application produces some log
> - My component read each log line generated and extract all the info, 
> based
> on log4j pattern used to produce that log
> 
> Any hints?
> Thanks in advance
> Gamby
> -- 
> View this message in context: 
> http://www.nabble.com/Extract-log-info-from-each-output-log-line-on-the-console-tp23813238p23813238.html
> 
> Sent from the Log4j - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Extract log info from each output log line on the console

Posted by Douglas E Wegscheid <Do...@whirlpool.com>.
if you have a chance to change the log file layout, use the XMLLayout. 
It's unambiguous to parse.

parsing the other layouts can be a problem (think about the situation of 
messages spanning multiple lines, or that have an exception trackback...)

Douglas E Wegscheid
Lead Technical Analyst, Whirlpool Corporation
(269)-923-5278

"A wrong note played hesitatingly is a wrong note. A wrong note played 
with conviction is interpretation."





gamby <ga...@libero.it> 
06/01/2009 07:00 AM
Please respond to
"Log4J Users List" <lo...@logging.apache.org>


To
log4j-user@logging.apache.org
cc

Subject
Extract log info from each output log line on the console







Hi all,

I'm developing a tool to do some auto statistics from the generated log of
an app...

I would like to be able to parse each log line generated obviously with 
lo4j
and extract all the info (timestamp, thread name, message and the others) 
in
a way that I could process separately those info.
Obviuosly I assume to know the pattern used to produce a log, knowing that
pattern, I would like to extract all the info.

For example if I know that a log file was produced using this pattern --> 
%d
%-5p [%t] - %m%n
Then I would like to extract from the generated log line, the timestamp, 
the
priority, the thread and the message, but without parsing the raw text 
using
string indexes for example....

And so the flow should be:
- An application produces some log
- My component read each log line generated and extract all the info, 
based
on log4j pattern used to produce that log

Any hints?
Thanks in advance
Gamby
-- 
View this message in context: 
http://www.nabble.com/Extract-log-info-from-each-output-log-line-on-the-console-tp23813238p23813238.html

Sent from the Log4j - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org