Click to See Complete Forum and Search --> : Can multiple config files be read for log4j?


wood_tah
07-08-2005, 07:45 AM
Can multiple config files be read when initializing log4j? For example, in my case, I am using WebLogic 8.1 and they have a default log4j config xml file that is read to initialize log4j. If I want to add specific configuration for my application, would I have to add to the existing WL log4j config, or could I have my own config file that is specific to my application? When I have my own config file, my goal is really to keep the logging that WL provides, but to ALSO include the logging config for my app. I know that I can rename the file and just point to the new file, I just want to be able to keep all of my app-specific configuration in one place, and the WL configuration in another, for ease of maintenence.

In summary, I guess I have the following questions:

Can multiple config files be read for log4j? If so, what happens?

- Does the config file that is loaded 2nd overwrite the 1st, or append to the first (provided there are no conflicts)

- Can the config files be a mix of xml and .properties files?

- Can they be loaded at different times (e.g. WL loads its default at server startup, but have my app-specific file loaded via an initialization servlet that reads a properties file via PropertyConfigurator.configure() ) ?

Thanks in advance for any input you may be able to provide.

Khalid Ali
07-08-2005, 11:40 AM
...
- Does the config file that is loaded 2nd overwrite the 1st, or append to the first (provided there are no conflicts)
the last one loaded will take precedence
...
- Can they be loaded at different times (e.g. WL loads its default at server startup, but have my app-specific file loaded via an initialization servlet that reads a properties file via PropertyConfigurator.configure() ) ?

Thanks in advance for any input you may be able to provide.
you are already on the right track, you can load a log4j properties file for each application deployed using
PropertyConfigurator.configure() ;
method

wood_tah
07-11-2005, 06:51 AM
the last one loaded will take precedence
When you say "take precedence", do you mean that only the second one loaded will apply, or are you saying that if there are any settings for the same logger, that those in the second will override the first? In my case, there should never be a case where what is in the second file would be defined in the first file. I really just want to keep the existing logging set up by the server (in case it is ever needed), but wanted to make administration of the logging for our app easier by having our own application-specific logging in its own separate file (therefore adding to the existing logging, instead of replacing it.