can i solve this problem without changing the PooledConnection class ? Mmmmmaybe.
I think that the
proper solution, if at all possible, is to change the PooledConnection class to make logger an instance variable, and make sure each logger gets created with a different name (unique to the PooledConnection instance). A simple way to do that is:
Technically the identityHashCode is not
guaranteed to be unique, but I'd be pretty surprised if it isn't. Or you can use some other method to ensure a unique name.
Now if you really can't change the PooledConnection code, it's tough. You can configure the Logger, adding two (or more) separate Handlers, each one intended to respond only to messages originating from a particular PooledConnection. How can a given Handler tell where a message originated? Looking at the information available in the LogRecord class, I don't see much that's useful to use here. Stuff like getSourceClassName() doesn't give us any info about which
instance issued a logging request. The only thing I see that
might work is getThreadID(). IF the two instances are running in different threads, then each Handler can respond only to a particular
Thread. Of course it's also possible that there are multiple Threads associated with each PooledConnection, so this could get messy. I'd say your best bet is to study the threading situation to see if this is a viable way to tell instances apart. Good luck.