You have four basic options:
class A1 {
static final Category LOG_B = Category.getInstance(B.class);
class B {
void m() {
LOG_B.info("Log msg");
}
}
}
class A2 {
static class B {
static final Category LOG_B = Category.getInstance(B.class);
void m() {
LOG_B.info("Log msg");
}
}
}
class A3 {
class B {
final Category LOG_B = Category.getInstance(B.class);
void m() {
LOG_B.info("Log msg");
}
}
}
class A4 {
class B {
void m() {
Category LOG_B = Category.getInstance(B.class);
LOG_B.info("Log msg");
}
}
}
A1 is efficient, but put the Category outside of where it "should" be. A2
is efficient and puts it where it "should" be, but only works if B does not
need instance info from A2. A3 is less efficient since every instance of B
will have to do the lookup and contain a the reference. (As Craig said,
though, there's only one INSTANCE of the Category ever created, so that's
not a problem.) A4 is even less efficient since that lookup is done each
time the method is called, but no extra reference is maintained.
>From there it is the standard engineering decisions between simplicity,
speed and space.
-Jim Moore
-----Original Message-----
From: Craig Newlander [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 17, 2001 4:14 PM
To: LOG4J Users Mailing List
Subject: RE: Categories for Inner Classes
I ran into the same scenario, The Catergoy Object is a factory so all
"instances" of Category using the same
foo.class will reference the same instance anyways. Can you give the inner
class a name?
-----Original Message-----
From: Stephen Levinson [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 17, 2001 3:02 PM
To: 'LOG4J Users Mailing List'
Subject: Categories for Inner Classes
Hi all...
In setting categories for classes I am using a STATIC instance of
Category ... sending in the class name.
If I have an inner class I'd like to be able to set a category with
ITS OWN NAME... but I can't use a STATIC in the inner class.
Is there any way to have the category for an inner class have its
own name?
Thanks in Advance, Stephen
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]