>Is the Repository(Hiearchy) the only approach?

Since you have found the source code for the offending code I think there
are at least two solutions:

1. Maintain your own Hierarchy. For example maintain a class,
MyLoggerFactory, that returns references to Log4J Logger but from a
'pristine' hierarchy that never gets modified by the default
PropertyConfigurator behavior. All of your code would need to be modified to
obtain a Logger from MyLoggerFactory.

2. Modify the source code by commenting out the call to
PropertyConfigurator. Compile it. Place it in the class path before the JDBC
driver. :)

I think (2) might be the fastest approach.


Naresh Sikha 



-----Original Message-----
From: Peake, Chris [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 20, 2004 12:04 PM
To: Log4J Users List
Subject: RE: Messages getting redirected to non related log file



Thanks for all the answers so far.
The problem with a reconfigure, is that I will have to do it a 1000+ times.
It is not like the situation where a JDBC driver get's loaded once and then
I could do a reconfigure.  The offending code is utilized much.

I found the source code for the offender.
It is as follows.

        String logPropFile = conf + "cpcm.properties";

        try
        {
            // initialize logging
            PropertyConfigurator.configure(logPropFile);
        }
        catch(Exception e)
        {
            System.out.println("Error: 4 - Could not initialize log4j");
        }

        cat.info("Inside Extractor()");

Poor yes, but not mine to change.

So for a quick and dirty try to fix, I coded this:
PropertyConfigurator.configure("log4j.properties");

It works to a large degree, the console works, but the 'file' appender does
not get reinited and thus is not updated. Also, the messages from the other
module is now coming into my console window.

Is the Repository(Hiearchy) the only approach?
I am not in a 'web' situation, simply a standalone (call other pgm
obviously).

Thanks,
 chris
 

-----Original Message-----
From: Sikha, Naresh [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 20, 2004 11:46 AM
To: 'Log4J Users List'
Subject: RE: Messages getting redirected to non related log file

The offending code is probably programmatically configuring log4j rather
than using a configuration file.

Barring LOG4J having a security mechanism the best you can do is to guard
your own code and configuration by maintaining your own
Repository(Hierarchy).

https://www.qos.ch/logging/sc.html is an excellent resource for managing
your own Repository.

Thanks.

Naresh Sikha 



-----Original Message-----
From: Peake, Chris [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 20, 2004 9:27 AM
To: [EMAIL PROTECTED]
Subject: Messages getting redirected to non related log file


I have a program that logs messages to the console and a file using the
correct appenders. Works great, until I call a 3rd party tool that seems to
be co-opting my logger somehow. As soon as that program is encountered, ALL
MY messages start going to his log file and no longer to MY logfile. My
appenders are all named differently.
 
I can't seem to find the root cause.
 
I've tried various releases of log4j.
 
Any ideas?
 
thanks,
 Chris

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



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

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

Reply via email to