Hi Ceki, I was reading the manual on Log4J site. I could not understand the following "Warning":
"Though the Redbook is undoubtedly motivated by the most noble intentions, I strongly discourage you from adopting its intialization wrapper (LogHelper) approach. The wrapper solution is highly intrusive and goes against the "separation of usage and configuration principle" so dear to log4j. This approach unfortunately continues to be suggested by well-meaning log4j users." By following this approach one will be insulating their code from the logging code and hence more desirable (at least to me). The LogHelper class mentioned in the Redbook does give you most of the functionality. Any insights would be really appreciated. Thanks, --Venkat. -----Original Message----- From: Ceki Gulcu [mailto:[EMAIL PROTECTED]] Sent: Monday, December 31,2001 7:26 AM To: Log4J Users List Subject: Re: Clearing loggers from the Hierarchy's internal hash table At 14:55 30.12.2001 -0600, you wrote: >Is there a way to clear logger entries from the Hierarchy class's internal >Hashtable? > >The issue I am trying to get around deals with the way in which I am >creating loggers for my User object. The Logger is an instance variable and >is created by: Logger.getLogger( "session." + user + "_" + session ). The >combination username plus HTTP session id will be pretty unique. After >looking through the code for LogManager, DefaultLoggerRepository, and >Hierarchy I have seen no place where the loggers are ever cleaned up (once >called they remain in the hierarchy's hashtable, thus preventing garbage >collection). I am afraid these log4j loggers will in essence become a >memory-leak, "clearable" only when the VM is shutdown. > >I understand that in the normal course/usage of log4j this is excatly what >you probably want to happen. But in my scenario, it can potentially be >pretty detrimental. > >Is there something I missed; someway to clear an individual entry from this >hashtable? > >If not, looks like I'll have to subclass or edit Hierarchy to add a >removeLogger method. Steve, Removing the logger from the hashtable is the easier part. You also have to link the children of the removed category with its nearest ancestor. You would also need to close the appenders of the removed logger but that's something that should be done before removing the logger not necessarily within the remove method. Regards, Ceki >What additional clean-up type methods should I call on >the Logger in that case? >Logger.removeAllAppenders()? >Any others? > >Thanks, >Steve -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>