From: Christopher J. B. <cjb...@al...> - 2004-09-01 19:38:15
|
thanks for the reply. well i guess its not so much the loggers (or categories) that i care about, but the appenders. so lets say that pluginA gets loaded and it creates a logger category (get_logger("My::PluginA")) and then programmatically sticks a file appender on it that logs to file pluginA.log. so pluginA does its stuff then is unloaded, etc. so what if pluginA gets loaded again, but this time it wants to attach a different appender to logger My::PluginA (maybe specify a different log file or something), but still use the same appender name. won't that not work as expected because now My::PluginA logger will have 2 appenders on it, when we only want one. err, actually it won't work because if the appender name already exists, the global appenders hash won't be updated. i've looked at the source for log4perl and if i'm not mistaken, add_appender() looks at the global hash of appenders by name to see if it already exists. if it does, it won't actually put the new appender in the global hash. so i guess my problem is that i'm not using the module like it was intended. each time a plugin in loaded, it programmatically constructs an appender, with the same name each time, but with possibly different attributes. any suggestions or tips? thank you. Mike Schilli wrote: > Christopher J. Bottaro wrote on 9/1/2004, 10:10 AM: > > > the problem is that when the module is unloaded, the > > logger is still there and after several loadings/unloadings, there are > > going to be many left over loggers and appenders sitting around in > memory. > > Loggers are singletons, get_logger($cat) just creates a logger for the > given category once and returns a reference to it on subsequent calls. > Unless you're requesting a logger for a different category every time, > this shouldn't cause any problems -- or is there anything unusual going > on when you 'unload' the module? > > -- > -- Mike > Mike Schilli > m...@pe... > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click |