Richard Burton richard-at-atomwide.com |log4perl_sourceforge| wrote:
> Hi all
> 
> I am trying to capture unhandled exceptions that are sent to STDERR,
> e.g. for example the following could would give such an error
[snip]
> 
> I can catch this using stealth as loggers outlined in
> 
> http://search.cpan.org/~mschilli/Log-Log4perl/lib/Log/Log4perl/FAQ.pm#So
> me_module_prints_messages_to_STDERR._How_can_I_funnel_them_to_Log::Log4p
> erl?
> 
> but the example assumes you are using the "easy" configuration method.
> 
> The question I have is can I do a similar thing but use an external
> configuration file for log4perl? I have tried but failed so would
> appreciate any guidance?


Here's what I did:
1.  Make a file "trapper.pl".  It's basically the same as the example,
except the Log4perl init, which uses a config file (in this case, with a
 SIGHUP to re-read it):

        ########################################
        package Trapper;
        ########################################

        use Log::Log4perl qw(get_logger :levels);

        Log::Log4perl->init_and_watch("../log4perl.conf",'HUP');
        my $logger = get_logger("program.category");


        sub TIEHANDLE {
        ... [etc]

2. In my perl program:
        require "trapper.pl";
        tie (*STDERR, 'Trapper');


HTH,
Rob




------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to