Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Possible scoping issue with Log::Log4perl logger

by trwww (Priest)
on Jun 16, 2018 at 16:05 UTC ( #1216779=note: print w/replies, xml ) Need Help??


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?

Replies are listed 'Best First'.
Re^2: Possible scoping issue with Log::Log4perl logger
by talexb (Canon) on Jun 16, 2018 at 16:37 UTC

    Thanks for the link to the documentation .. I guess I'm being thick, but it strikes me that the script ending would mean that the logger goes out of scope .. which should send the E-Mail.

    But I'm going to have to do some testing on that aspect of things. Appreciate the feedback. :)

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1216779]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2020-12-05 17:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (64 votes). Check out past polls.

    Notices?