I want to change the logging level while instances of the same class are running, so 
this makes it difficult as how do I know that is the output of 

getClass() + String.valueOf(hashCode())

because I want to change the level from the log4j.properties.

What I want to know if, say, multiple forms (of the same class type) are running to 
monitor different devices, let's say one them is behaving strange, so I need to change 
the debug level of only that one.

S.


-----Original Message-----
From: Shapira, Yoav [mailto:[EMAIL PROTECTED]
Sent: 14 November 2003 13:53
To: Log4J Developers List
Subject: RE: Instance logging



Howdy,
You can't if you associate the logger with the class rather than the
instance, which is what most people do.  Most people do something like:
private static final Logger LOGGER = Logger.getLogger(ThisClass.class);

In that case all instances of ThisClass at runtime share the same
logger.  However, there's nothing to prevent you from having different
loggers for each instance.  For example, you could do:

private Logger logger;

public ThisClass() {
  logger = Logger.getLogger(getClass() + String.valueOf(hashCode());
}

Then you can individually modify the level for the Logger if you're
given the ThisClass object.

But this is kind of unusual, why do you want to do it?

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Sahraei Sasan-ssahra01 [mailto:[EMAIL PROTECTED]
>Sent: Friday, November 14, 2003 8:49 AM
>To: 'Log4J Developers List'
>Subject: Instance logging
>
>Hi,
>
>A question about log4j. Is I create a category of logging for a class
type
>and during run time if multiple instances of that class are running and
I
>just want to change the logging level for only one running instance of
that
>class type, what would be the way?
>
>Thanks,
>S.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


---------------------------------------------------------------------
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