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 "Gaussmann, Horst" <Ho...@db-ig.com> on 2001/08/21 11:49:22 UTC

AW: we are stuck : HOW TO use more that 1 configuration file in 1 app ????

Don't know if this can be resolved with log4j.
My hint for you is. For every Client you have to use your own Classloader. 
Inside this Classloader you can load the configuration new for each client. 
Now how to access this configuration - the Classloader must be set as a
Thread ContextClassLoader.
So when u access your log4j inside this Thread you'll get the Configuration
loaded with the assigned ContextClassLoader.
May be this is to complicated ... just a possible solution ... hope there
are simpler ones

then horst

-----Ursprüngliche Nachricht-----
Von: Alain RAVET [mailto:aravet@cirb.irisnet.be]
Gesendet am: Dienstag, 21. August 2001 10:47
An: LOG4J Users Mailing List
Betreff: we are stuck : HOW TO use more that 1 configuration file in 1
app ????

Hi to all, 
(This is a little longish, but I had to add words to make things clear.
We are stuck. 
Please read till the end).


***********
Question :
***********
How to use more that 1 configuration file in 1 app :


***********
Problem : 
***********
PropertyConfigurator.configure(.) overwrites previous choices


***********
Usage :
***********
We are building a simple log relayer/dispatcher, that listens on 
socket ports, and relays/resends incoming logEvents with log4j,
to other log4j appenders, or even another relaye.


Each port is dedicated to 1 client application.

ex : 
   port 2010 = logs coming from app "x1"
   port 2011 = logs coming from app "x2"


Obviously, the logging requirements are not the same for each app.,
so we want to use 1 log4j configuration file for each app/port

ex : 
   conf_2010.log4j = log4j instructions to relay app "x1" logEvents
   conf_2011.log4j = log4j instructions to relay app "x1" logEvents

***********
Problem : 
***********
PropertyConfigurator.configure(.) is static, and 
overwrites previous choices


***********
How to reproduce
***********

with 

file: conf_2010.log4j :
---------------------- 
    ...
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    og4j.appender.stdout.layout.ConversionPattern=***********%m%n
    ...

file: conf_2011.log4j :
---------------------- 
    (idem but for :
    og4j.appender.stdout.layout.ConversionPattern=------------%m%n


test code : 
--------------------
  public class spike () {
    public static void main (..){
    //
        PropertyConfigurator.configureAndWatch( file1_tirets );
        cat1 = Category.getInstance("cat1");
        cat1 .debug("text 1");

    //
        PropertyConfigurator.configureAndWatch( file2_stars );
        cat2 = Category.getInstance("cat2");
        cat2 .debug("text 2");

        cat1 .debug("text 1");
        cat2 .debug("text 2");

     }
   }


Result :
       ***********text1
       -----------text2
       -----------text1
       -----------text2

I want to obtain :


       ***********text1
       -----------text2
       ***********text1
       -----------text2



Is there a solution to this problem?
We are stuck.
Thanks in advance

Alain Ravet
Brussels, Belgium

This mail has been checked by exiscan.
To be safe, please scan the mail attachements with your local virus scanner
!

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

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