logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Moran Ben-David" <mo...@place-base.com>
Subject RE: Apache Commons Collection - CompositeConfiguration
Date Sun, 24 Jul 2005 17:14:57 GMT
Thanks for your input, Mark.

I finally found time to play with log4j to have it read a configuration as a
union of several files.  I managed to do it in a much easier way than I
thought initially.  I just wanted to share with the group.

I did it via multiple calls to

	PropertyManager.configure(String filename)

That is.. I did something like

	PropertyManager.confiure("file1.properties");
	PropertyManager.confiure("file2.properties");

And the latter call to configure produced an overwrite of any shared
properties between the two files.  I did this with the new alpha release
(1.3alpha-6), not sure about the older releases.  That is, I'm assuming this
behaviour of allowing multiple files has been around for a while.

Though it seems right to mix in the apache common configuration package into
log4j, it is beyond my requirements right now.

Thanks again for your input, and needless to say, thanks to log4j and its
developers for making my life easier.

Moran

> -----Original Message-----
> From: Mark Womack [mailto:womack@adobe.com]
> Sent: Monday, July 18, 2005 8:02 PM
> To: 'Log4J Users List'
> Subject: RE: Apache Commons Collection - CompositeConfiguration
> 
> Well, if CompositeConfiguration supports getting a Properties object to
> represent the configuration settings, then you could plug it into the
> PropertyConfigurator through doConfigure(Properties, LoggerRepository)
> pretty easily.  Though there is no way to do automatic, default
> configuration (ie a single property or xml file).  You'll have to write
> your
> on code to create the CompositeConfiguration and then pass it into
> PropertyConfigurator.
> 
> <related-but-not-exactly-helpful-to-your-current-context>
> I think it is a weakness of the Configurator interface that it requires
> you
> to support/specify a file, etc.  And then each configurator has to define
> source specific methods.  It would be nice if it could use a "wrapper"
> interface where implementations could wrap a file, or a stream, or a
> CompositeConfiguration, etc.  Haven't thought about it very hard, so not
> sure what it would look like, but something that says "give me all the
> appender settings configured in this configuration", "give me all the
> logger
> settings configured in this configuration", etc.  Leave it up to the
> implementation to figure out the details.  Then the common code would be
> responsible for actually configuring the environment using the data.  Hm.
> </related-but-not-exactly-helpful-to-your-current-context>
> 
> -Mark
> 
> > -----Original Message-----
> > From: Moran Ben-David [mailto:moran@place-base.com]
> > Sent: Monday, July 18, 2005 3:48 PM
> > To: log4j-user@logging.apache.org
> > Subject: Apache Commons Collection - CompositeConfiguration
> >
> > Hi.
> >
> >
> >
> > I am looking to configure Log4J in my app to use a composite
> configuration
> > (one based on multiple files).  Has anyone done this before?  (I
> searched
> > the list and didn't find any mention of it.)   Am I correct in wanting
> to
> > extend through org.apache.log4j.config to do this?
> >
> >
> >
> > Does anyone have information on how to use the
> >
> >
> >
> >             org.apache.log4j.config
> > <http://logging.apache.org/log4j/docs/api-
> > unstable/org/apache/log4j/config/p
> > ackage-frame.html>
> >
> >
> >
> > package and extend with it?  I'm going through the javadoc but was
> hoping
> > that someone else was kind enough to document this process.
> >
> >
> >
> > Here's more info on what I'm trying to do in case anyone is kind enough
> to
> > lend some eyes and braincells:
> >
> >
> >
> > I want the configuration that log4j will use to be derived from a series
> > of
> > files and not just from a single file.  Propreties existing in two
> files,
> > will be overriden by the higher priority file (i.e. the earlier one in
> the
> > list or vice versa).
> >
> >
> >
> > I'm thinking that the best way to do this is to use the Apache Common
> > Configuration framework's CompositeConfiguration:
> >
> >
> >
> > CompositeConfiguration config = new CompositeConfiguration();
> > config.addConfiguration(new SystemConfiguration());
> > config.addConfiguration(new
> > PropertiesConfiguration("application.properties"));
> >
> >
> >
> > And then to get Log4J to pickup it's configuration from that "config"
> > object.  Now comes the task of plugging into log4j.
> >
> >
> >
> > Any answers to the questions above would be greatly appreciated.
> >
> >
> >
> > Thanks
> >
> > Moran Ben-David
> >
> > http://www.place-base.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


Mime
View raw message