http://www.perlmonks.org?node_id=1216779


in reply to Possible scoping issue with Log::Log4perl logger

I've poked the Log::log4perl internals a bit before, but I don't have any of it memorized so this is mostly guesses but:

Anyway, my workaround is going to be to call get_logger in whichever scope I need to do logging.

Right, this is what you have to do here. Sounds like you understand why.

but I'm left wondering why doesn't Log::Log4perl see that the logger has gone out of scope in the work script and send the E-Mail?

For the same reason you can call ->get_logger without specifying the config again and get the expected logger object. Even though its went out of scope in your block, the instance of your logging object still exists in log4perl, so its not went out of scope everywhere yet. If you read through the l4p FAQ and review the email and buffering parts, it might might help explain whats going on? #How-can-I-configure-Log::Log4perl-to-send-me-email-if-something-happens?