Howdy,

>2. Is it possible to associated a log file to an INSTANCE of an object?
I
>have object which does quite complex things and which is constructed
with
>an Id. I would like to associate one log file per instance, such as
log-id1
>and log-id2 if I do new ComplexObject("id1); and new
ComplexObject("id2");

I think there's a relatively simple solution for this one.  Don't use
static loggers.  Get the logger in the constructor, e.g.

private final Logger myLogger;
private final Appender myAppender;

public myClass(int id)
{
    ...
    myLogger = Logger.getLogger(myClass.class.getName() + id);
   
    // Configure myAppender, if it hasn't been done yet.
    // Add myAppender to myLogger.
    
}

That said, I don't think the one object instance per logger concept is
that good.  But it's your use case, your system ;)

Yoav Shapira
Millennium ChemInformatics

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

Reply via email to