Hi all,

Is it possible to define two or more different logger objects in one Java Program? I 
am trying to create an own logger for each created object in the program, but using 
the instance Logger.getLogger(name) makes this no possible because when I create the 
second instance I "loose" the reference to the first one, probably because using 
static variables that changes and each object is using. Don't know how to do...

I have tested if it's possible with the following example code:

        this.logger1 = Logger.getLogger(MyClass.class.getName()+name1);
        PropertyConfigurator.configure("log4j.properties");
        logger1.info("- Logging initialized --");
        
        this.logger2 = Logger.getLogger(ApiTesterTool.class.getName()+name2);
        PropertyConfigurator.configure("log4j.properties");
        logger2.info("- Logging initialized --");
        
        // Till here the code works perfectly, the first logging information is 
written in one file and the other in the other one
        // Next line pretends to write again in logger1
        
        logger1.info("This line must be written in file defined by logger1 but is 
written in logger2 !!!!!!!!");

Please help a poor Java programmer ;-)

Jaume

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to