Hi,

I need your expert advice here. The Log4JLogger class is declared as a final
class. In my code, I use :

Logger logger = new Log4JLogger(
    Category.getInstance(targetName));

This is used in a generic method that is called to automatically log entries
and exits of methods, so it is executed every time there is a log to be made
for an entry/exit. It is thus called very often.

I'd like to know if it has any performance issue. More specifically, I'd
like to know if the final keyword helps for performance (as it does for
final methods which are inlined) : I guess that even with the final keyword,
there is always a new object instanciated in memory ...

So, I also guess that simply writing :

Category category = Category.getInstance(targetName);

would be more performant ?

Another solution would be to have a hashmap of all loggers and check in the
hashmap whether the logger for a given targetName already exist and then use
that logger if it does. However, the additional work (putting the instances
in the hash, possibly with synchronisation (argh!), then doing an "if" and
then fetching the logger from the hash) might overall be more costly that
instanciating a new object.

What do you think ? Any idea ?
Thanks
-Vincent



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

Reply via email to