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 Christophe Elek <ce...@ca.ibm.com> on 2009/03/09 15:08:39 UTC

Using log4j.properties to handle other properties

My developers are using System Properties to enable certain trace options
(like collecting statistics)
Is there a way I could define such property in the log4j.properties instead
so we keep trace/log options and metadata together ?

So my developers will do
<aLog 4J object>.getProperty('my property') instead of System.getProperty()
?

Christophe Elek - Senior Software Analyst
IBM Rational Serviceability Architect
IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7
Phone Number: (905) 413-3467
Email: celek@ca.ibm.com

Rational Internal Serviceability Portal
"Don't just fix the mistakes - fix whatever permitted the mistake in the
first place." Charles Fishman

Web:http://www.ibm.com/software/rational/

Re: import log into java model using log4j.properties

Posted by Scott Deboy <sc...@gmail.com>.
The receiver can handle multi-line messages, but it isn't foolproof.  If
there's a choice, using XMLLayout will give you more predictable results.

Scott

On Wed, Mar 25, 2009 at 7:53 AM, Douglas E Wegscheid <
Douglas_E_Wegscheid@whirlpool.com> wrote:

> you could, but you still have the problem of handling multi-line messages.
> if you have the option to change layout, xmllayout is pretty foolproof...
>
> 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."
>
>
>
> Christophe Elek <ce...@ca.ibm.com> wrote on 03/25/2009 10:38:30 AM:
>
> > Hey Doug,
> > Yes I agree
> >
> > I was thinking I could use the same ConversionPattern
> >
> > So if my log4j properties lists
> >
> > log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} [%t] %5p
> > %-50.50c - %m%n
> >
> > it would use the ConversionPatten as a regex and read each line ??
> >
> > am I dreaming ? :)
> >
> > Christophe Elek - Senior Software Analyst
> > IBM Rational Serviceability Architect
> > IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7
> > Phone Number: (905) 413-3467
> > Email: celek@ca.ibm.com
> >
> > Rational Internal Serviceability Portal
> > "Don't just fix the mistakes - fix whatever permitted the mistake in
> > the first place." Charles Fishman
> > [image removed]
> > Web:http://www.ibm.com/software/rational/
> >
> > [image removed] Douglas E Wegscheid ---03/25/2009 10:14:11 AM---
> > doing this with an arbitrary layout would be quite daunting.
>
> >
> > [image removed]
> > From:
> >
> > [image removed]
> > Douglas E Wegscheid <Do...@whirlpool.com>
> >
> > [image removed]
> > To:
> >
> > [image removed]
> > "Log4J Users List" <lo...@logging.apache.org>
> >
> > [image removed]
> > Cc:
> >
> > [image removed]
> > "Log4J Users List" <lo...@logging.apache.org>
> >
> > [image removed]
> > Date:
> >
> > [image removed]
> > 03/25/2009 10:14 AM
> >
> > [image removed]
> > Subject:
> >
> > [image removed]
> > Re: import log into java model using log4j.properties
> >
> >
> >
> >
> > doing this with an arbitrary layout would be quite daunting.
> >
> > if you use XMLLayout, then reading the XML and doing what you want would
>
> > be quite simple.
> >
> > 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."
> >
> >
> >
> > Christophe Elek <ce...@ca.ibm.com> wrote on 03/25/2009 09:03:36 AM:
> >
> > > I am looking for a solution that would do the 'reverse' of logging
> > > into a log file: reading a log file into java obects.
> > >
> > > I want a tool that would take a log4j.properties, a log generated
> > > using this log4j.properties and would transform each event into an
> > object
> > > Then I can run an analyzer :)
> > >
> > > Does it make sense ? :)
> > >
> > > Christophe Elek - Senior Software Analyst
> > > IBM Rational Serviceability Architect
> > > IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7
> > > Phone Number: (905) 413-3467
> > > Email: celek@ca.ibm.com
> > >
> > > Rational Internal Serviceability Portal
> > > "Don't just fix the mistakes - fix whatever permitted the mistake in
> > > the first place." Charles Fishman
> > > [image removed]
> > > Web:http://www.ibm.com/software/rational/
>

Re: import log into java model using log4j.properties

Posted by Scott Deboy <sc...@gmail.com>.
LogFilePatternReceiver will do this...you'd have to write a simple appender
that processes the events the are generated by the receiver.  Both your
appender and the receiver need to be added to the log4j configuration file.

Scott

On Wed, Mar 25, 2009 at 7:38 AM, Christophe Elek <ce...@ca.ibm.com> wrote:

> Hey Doug,
> Yes I agree
>
> I was thinking I could use the same ConversionPattern
>
> So if my log4j properties lists
>
> log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} [%t] %5p
> %-50.50c - %m%n
>
> it would use the ConversionPatten as a regex and read each line ??
>
> am I dreaming ? :)
>
>
> Christophe Elek - Senior Software Analyst
> IBM Rational Serviceability Architect
> IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7
> Phone Number: (905) 413-3467
> Email: celek@ca.ibm.com
> *
> **Rational Internal Serviceability Portal*<http://w3.rchland.ibm.com/projects/process/swg/rational/serviceability/serviceability.shtml>
> "Don't just fix the mistakes - fix whatever permitted the mistake in the
> first place." Charles Fishman
> ------------------------------
>
> Web:http://www.ibm.com/software/rational/
> ------------------------------
>
>
> [image: Inactive hide details for Douglas E Wegscheid ---03/25/2009
> 10:14:11 AM---doing this with an arbitrary layout would be quite da]Douglas
> E Wegscheid ---03/25/2009 10:14:11 AM---doing this with an arbitrary layout
> would be quite daunting.
>
>
> From:
> Douglas E Wegscheid <Do...@whirlpool.com>
> To:
> "Log4J Users List" <lo...@logging.apache.org>
> Cc:
> "Log4J Users List" <lo...@logging.apache.org>
> Date:
> 03/25/2009 10:14 AM
> Subject:
> Re: import log into java model using log4j.properties
> ------------------------------
>
>
>
> doing this with an arbitrary layout would be quite daunting.
>
> if you use XMLLayout, then reading the XML and doing what you want would
> be quite simple.
>
> 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."
>
>
>
> Christophe Elek <ce...@ca.ibm.com> wrote on 03/25/2009 09:03:36 AM:
>
> > I am looking for a solution that would do the 'reverse' of logging
> > into a log file: reading a log file into java obects.
> >
> > I want a tool that would take a log4j.properties, a log generated
> > using this log4j.properties and would transform each event into an
> object
> > Then I can run an analyzer :)
> >
> > Does it make sense ? :)
> >
> > Christophe Elek - Senior Software Analyst
> > IBM Rational Serviceability Architect
> > IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7
> > Phone Number: (905) 413-3467
> > Email: celek@ca.ibm.com
> >
> > Rational Internal Serviceability Portal
> > "Don't just fix the mistakes - fix whatever permitted the mistake in
> > the first place." Charles Fishman
> > [image removed]
> > Web:http://www.ibm.com/software/rational/
>
>

Re: import log into java model using log4j.properties

Posted by Douglas E Wegscheid <Do...@whirlpool.com>.
you could, but you still have the problem of handling multi-line messages. 
if you have the option to change layout, xmllayout is pretty foolproof...

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."



Christophe Elek <ce...@ca.ibm.com> wrote on 03/25/2009 10:38:30 AM:

> Hey Doug,
> Yes I agree
> 
> I was thinking I could use the same ConversionPattern 
> 
> So if my log4j properties lists
> 
> log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} [%t] %5p
> %-50.50c - %m%n
> 
> it would use the ConversionPatten as a regex and read each line ??
> 
> am I dreaming ? :)
> 
> Christophe Elek - Senior Software Analyst
> IBM Rational Serviceability Architect 
> IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7 
> Phone Number: (905) 413-3467 
> Email: celek@ca.ibm.com
> 
> Rational Internal Serviceability Portal
> "Don't just fix the mistakes - fix whatever permitted the mistake in
> the first place." Charles Fishman 
> [image removed] 
> Web:http://www.ibm.com/software/rational/ 
> 
> [image removed] Douglas E Wegscheid ---03/25/2009 10:14:11 AM---
> doing this with an arbitrary layout would be quite daunting.

> 
> [image removed] 
> From:
> 
> [image removed] 
> Douglas E Wegscheid <Do...@whirlpool.com>
> 
> [image removed] 
> To:
> 
> [image removed] 
> "Log4J Users List" <lo...@logging.apache.org>
> 
> [image removed] 
> Cc:
> 
> [image removed] 
> "Log4J Users List" <lo...@logging.apache.org>
> 
> [image removed] 
> Date:
> 
> [image removed] 
> 03/25/2009 10:14 AM
> 
> [image removed] 
> Subject:
> 
> [image removed] 
> Re: import log into java model using log4j.properties
> 
> 
> 
> 
> doing this with an arbitrary layout would be quite daunting.
> 
> if you use XMLLayout, then reading the XML and doing what you want would 

> be quite simple.
> 
> 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."
> 
> 
> 
> Christophe Elek <ce...@ca.ibm.com> wrote on 03/25/2009 09:03:36 AM:
> 
> > I am looking for a solution that would do the 'reverse' of logging 
> > into a log file: reading a log file into java obects.
> > 
> > I want a tool that would take a log4j.properties, a log generated 
> > using this log4j.properties and would transform each event into an 
> object 
> > Then I can run an analyzer :)
> > 
> > Does it make sense ? :)
> > 
> > Christophe Elek - Senior Software Analyst
> > IBM Rational Serviceability Architect 
> > IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7 
> > Phone Number: (905) 413-3467 
> > Email: celek@ca.ibm.com
> > 
> > Rational Internal Serviceability Portal
> > "Don't just fix the mistakes - fix whatever permitted the mistake in
> > the first place." Charles Fishman 
> > [image removed] 
> > Web:http://www.ibm.com/software/rational/ 

Re: import log into java model using log4j.properties

Posted by Christophe Elek <ce...@ca.ibm.com>.
Hey Doug,
Yes I agree

I was thinking I could use the same ConversionPattern

So if my log4j properties lists

log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} [%t] %5p
%-50.50c  - %m%n

it would use the ConversionPatten as a regex  and read each line ??

am I dreaming ? :)

Christophe Elek - Senior Software Analyst
IBM Rational Serviceability Architect
IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7
Phone Number: (905) 413-3467
Email: celek@ca.ibm.com

Rational Internal Serviceability Portal
"Don't just fix the mistakes - fix whatever permitted the mistake in the
first place." Charles Fishman

Web:http://www.ibm.com/software/rational/


                                                                                                                                         
  From:       Douglas E Wegscheid <Do...@whirlpool.com>                                                                    
                                                                                                                                         
  To:         "Log4J Users List" <lo...@logging.apache.org>                                                                         
                                                                                                                                         
  Cc:         "Log4J Users List" <lo...@logging.apache.org>                                                                         
                                                                                                                                         
  Date:       03/25/2009 10:14 AM                                                                                                        
                                                                                                                                         
  Subject:    Re: import log into java model using log4j.properties                                                                      
                                                                                                                                         





doing this with an arbitrary layout would be quite daunting.

if you use XMLLayout, then reading the XML and doing what you want would
be quite simple.

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."



Christophe Elek <ce...@ca.ibm.com> wrote on 03/25/2009 09:03:36 AM:

> I am looking for a solution that would do the 'reverse' of logging
> into a log file: reading a log file into java obects.
>
> I want a tool that would take a log4j.properties, a log generated
> using this log4j.properties and would transform each event into an
object
> Then I can run an analyzer :)
>
> Does it make sense ? :)
>
> Christophe Elek - Senior Software Analyst
> IBM Rational Serviceability Architect
> IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7
> Phone Number: (905) 413-3467
> Email: celek@ca.ibm.com
>
> Rational Internal Serviceability Portal
> "Don't just fix the mistakes - fix whatever permitted the mistake in
> the first place." Charles Fishman
> [image removed]
> Web:http://www.ibm.com/software/rational/

Re: import log into java model using log4j.properties

Posted by Douglas E Wegscheid <Do...@whirlpool.com>.
doing this with an arbitrary layout would be quite daunting.

if you use XMLLayout, then reading the XML and doing what you want would 
be quite simple.

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."



Christophe Elek <ce...@ca.ibm.com> wrote on 03/25/2009 09:03:36 AM:

> I am looking for a solution that would do the 'reverse' of logging 
> into a log file: reading a log file into java obects.
> 
> I want a tool that would take a log4j.properties, a log generated 
> using this log4j.properties and would transform each event into an 
object 
> Then I can run an analyzer :)
> 
> Does it make sense ? :)
> 
> Christophe Elek - Senior Software Analyst
> IBM Rational Serviceability Architect 
> IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7 
> Phone Number: (905) 413-3467 
> Email: celek@ca.ibm.com
> 
> Rational Internal Serviceability Portal
> "Don't just fix the mistakes - fix whatever permitted the mistake in
> the first place." Charles Fishman 
> [image removed] 
> Web:http://www.ibm.com/software/rational/ 

import log into java model using log4j.properties

Posted by Christophe Elek <ce...@ca.ibm.com>.
I am looking for a solution that would do the 'reverse' of logging into a
log file: reading a log file into java obects.

I want a tool that would take a log4j.properties, a log generated using
this log4j.properties and would transform each event into an object
Then I can run an analyzer :)

Does it make sense ? :)

Christophe Elek - Senior Software Analyst
IBM Rational Serviceability Architect
IBM Toronto Lab 8200 Warden Avenue, Markham, Ontario, L6G 1C7
Phone Number: (905) 413-3467
Email: celek@ca.ibm.com

Rational Internal Serviceability Portal
"Don't just fix the mistakes - fix whatever permitted the mistake in the
first place." Charles Fishman

Web:http://www.ibm.com/software/rational/