I use Log4perl as part of a package to capture what a particular DBI connection does. My current plan is to create a new log object for each connection via Log::Log4perl->get_logger($mysql_connect_id) , which should allow different connections to write to different files or the same file without screwing each other.
My concern is what happens when the connection is disconnected and that the registrar is no longer needed. If Log4perl just keeps these logs indefinitely, it sounds like a memory leak recipe.
What is the best way to get rid of the registrar after I am sure that it is no longer useful? Or, on the contrary, is this even a problem - does Log4perl have some kind of built-in removal mechanism that already prevents such leaks?
Edit: Mentioned in the comments on the question, it might be worth mentioning here: Log :: Log4perl :: Logger has a
DESTROY method that seems promising. However, it is undocumented and gives a bunch of warnings "Using uninitialized value in string equalizers", which makes me wary; it looks like a hack. (But if this is the best / only way to do this, I assume the question would be "How to disable a specific warning coming from a specific package?")
source share