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 jaikiran pai <ja...@yahoo.co.in> on 2006/06/23 11:55:32 UTC

Adding multiple configuration files to log4j

Hi,
 Currently, i could not find a way to use add multiple files as configuration files for log4j. Here's why i needed the same:
 
 - I have a 3rd party application which uses log4j and has its configurations in log4j.xml
 - I am integrating my application with the 3rd party application. 
 - My application also uses log4j and configures the same using say myAppLog4j.xml. 
 - I could have added(appended) my configurations to the log4j.xml used by the 3rd party application
 - But i would like to maintain both these configurations in 2 files.
 - The way i tell log4j to configure using myAppLog4j.xml is by using:
 
PropertyConfigurator.configure(Loader.getResource("myAppLog4j.xml"));
  Using this will make log4j configure *only* through myAppLog4j.xml. It would be really great, if we could have a API, something like:
  addConfiguration(String fileName); 
or
addConfiguration(File file);
or maybe
addConfiguration(Resource configResource);
  All these APIs would add the config file to a collection which will maintain the configuration files.
  Log4j could then maintain a collection of configuration files to use for configuring log4j.
  Is this possible? Or currently is there some way through which i can do the same?
   
   
  regards,
  -Jaikiran

 				
---------------------------------
 Yahoo! India Answers: Share what you know. Learn something new Click here
Catch all the FIFA World Cup 2006 action on Yahoo! India Click here

Re: Adding multiple configuration files to log4j

Posted by Jacob Kjome <ho...@visi.com>.
You can [re]configure Log4j as many times as you want.  Configuration 
is additive.  Once reconfiguration does not blow away the old.  I'm 
not sure what you describe is something Log4j ought to support at its 
core.  You are welcome to create your own startup class that behaves 
this way and just applies each configuration in turn.  However, I 
think this would become confusing.  The parent application is really 
the master of configuration.  Libraries shouldn't force a 
configuration on application code.  It is the end-user (developer) 
that cares about what they want to see in the logs, not the 
library.  I suggest you make it easier on yourself and put any 
configuration you desire into one file.

Jake

At 04:55 AM 6/23/2006, you wrote:
 >Hi,
 > Currently, i could not find a way to use add multiple files as
 >configuration files for log4j. Here's why i needed the same:
 >
 > - I have a 3rd party application which uses log4j and has its
 >configurations in log4j.xml
 > - I am integrating my application with the 3rd party application.
 > - My application also uses log4j and configures the same using say
 >myAppLog4j.xml.
 > - I could have added(appended) my configurations to the log4j.xml
 >used by the 3rd party application
 > - But i would like to maintain both these configurations in 2 files.
 > - The way i tell log4j to configure using myAppLog4j.xml is by using:
 >
 >PropertyConfigurator.configure(Loader.getResource("myAppLog4j.xml"));
 >  Using this will make log4j configure *only* through myAppLog4j.xml.
 >It would be really great, if we could have a API, something like:
 >  addConfiguration(String fileName);
 >or
 >addConfiguration(File file);
 >or maybe
 >addConfiguration(Resource configResource);
 >  All these APIs would add the config file to a collection which will
 >maintain the configuration files.
 >  Log4j could then maintain a collection of configuration files to use
 >for configuring log4j.
 >  Is this possible? Or currently is there some way through which i can
 >do the same?
 >
 >
 >  regards,
 >  -Jaikiran
 >
 >
 >---------------------------------
 > Yahoo! India Answers: Share what you know. Learn something new Click here
 >Catch all the FIFA World Cup 2006 action on Yahoo! India Click here


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


Re: Adding multiple configuration files to log4j

Posted by jaikiran pai <ja...@yahoo.co.in>.
Thanks, James. Will try out RepositorySelector.
   
  -Jaikiran

James Stauffer <st...@gmail.com> wrote:
  Search for something called a RepositorSelector (or something like that).

On 6/23/06, jaikiran pai wrote:
> Hi,
> Currently, i could not find a way to use add multiple files as configuration files for log4j. Here's why i needed the same:
>
> - I have a 3rd party application which uses log4j and has its configurations in log4j.xml
> - I am integrating my application with the 3rd party application.
> - My application also uses log4j and configures the same using say myAppLog4j.xml.
> - I could have added(appended) my configurations to the log4j.xml used by the 3rd party application
> - But i would like to maintain both these configurations in 2 files.
> - The way i tell log4j to configure using myAppLog4j.xml is by using:
>
> PropertyConfigurator.configure(Loader.getResource("myAppLog4j.xml"));
> Using this will make log4j configure *only* through myAppLog4j.xml. It would be really great, if we could have a API, something like:
> addConfiguration(String fileName);
> or
> addConfiguration(File file);
> or maybe
> addConfiguration(Resource configResource);
> All these APIs would add the config file to a collection which will maintain the configuration files.
> Log4j could then maintain a collection of configuration files to use for configuring log4j.
> Is this possible? Or currently is there some way through which i can do the same?
>
>
> regards,
> -Jaikiran
>
>
> ---------------------------------
> Yahoo! India Answers: Share what you know. Learn something new Click here
> Catch all the FIFA World Cup 2006 action on Yahoo! India Click here
>


-- 
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

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



 				
---------------------------------
 Yahoo! India Answers: Share what you know. Learn something new Click here
Catch all the FIFA World Cup 2006 action on Yahoo! India Click here

Re: Adding multiple configuration files to log4j

Posted by James Stauffer <st...@gmail.com>.
Search for something called a RepositorSelector (or something like that).

On 6/23/06, jaikiran pai <ja...@yahoo.co.in> wrote:
> Hi,
>  Currently, i could not find a way to use add multiple files as configuration files for log4j. Here's why i needed the same:
>
>  - I have a 3rd party application which uses log4j and has its configurations in log4j.xml
>  - I am integrating my application with the 3rd party application.
>  - My application also uses log4j and configures the same using say myAppLog4j.xml.
>  - I could have added(appended) my configurations to the log4j.xml used by the 3rd party application
>  - But i would like to maintain both these configurations in 2 files.
>  - The way i tell log4j to configure using myAppLog4j.xml is by using:
>
> PropertyConfigurator.configure(Loader.getResource("myAppLog4j.xml"));
>   Using this will make log4j configure *only* through myAppLog4j.xml. It would be really great, if we could have a API, something like:
>   addConfiguration(String fileName);
> or
> addConfiguration(File file);
> or maybe
> addConfiguration(Resource configResource);
>   All these APIs would add the config file to a collection which will maintain the configuration files.
>   Log4j could then maintain a collection of configuration files to use for configuring log4j.
>   Is this possible? Or currently is there some way through which i can do the same?
>
>
>   regards,
>   -Jaikiran
>
>
> ---------------------------------
>  Yahoo! India Answers: Share what you know. Learn something new Click here
> Catch all the FIFA World Cup 2006 action on Yahoo! India Click here
>


-- 
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

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