Components subclass with log4j Logger
Components subclass with log4j Logger
- Subject: Components subclass with log4j Logger
- From: Florijan Stamenkovic <email@hidden>
- Date: Sun, 10 Jul 2005 15:07:30 +0200
Hi all.
I made a construction in which I have a subclass of WOComponent called
MyWOComponent that is a superclass for all my components. In it I have
defined a static Logger instance with the idea that then all my
component classes will automatically have a logger, and that I can log
the RR loop on all of them (if needed) with minimal effort.
Now, my idea was that the attempt to instantiate the Logger can be
placed in the MyWOComponent's constructor. That way the static
per-class logger is created only when the first instance of the
component is asked for (before that it is null). Since log4j returns
the already existing logger if it can find one for the name that the
request came with, I should end up with one Logger instance per class.
MyWOComponent constructor logs every new instance into the class logger
just after getLogger() method. This gives the desired output (output
from a logger with the name of the subclass). From which I conclude
that the system is functional. However, whenever I log from within the
subclass itself (so, the actual component class), the logger that gives
the output is the TopWrapper logger. TopWrapper is a component class
(also a subclass of MyWOComponent) that is one of the few full HTML
documents in the project. Most other components are wrapped in it
(directly, or indirectly through another wrapper). So, the log requests
called within one class somehow reach the logger of the TopWrapper
component.
This looks pretty strange to me, and I have no idea how it is
possible... Can anybody make anything out of it???
Oh, and I do have a workaround for it. Not make my wrapper components
subclass MyWOComponent, but just the plain old WOComponent :) Still, it
would be nice to understand why that behavior is there.
Flor
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden