From: Seth D. <log...@se...> - 2009-05-09 07:40:02
|
On Sat, May 09, 2009 at 12:12:28AM -0700, Mike Schilli wrote: > On Fri, 8 May 2009, Seth Daniel wrote: > >> The reason for this is that I have a number of existing programs that >> use Log4perl for most logging, but some very specific logging does not >> use Log4perl. I need to be able to use a single signal to tell both >> Log4perl and the other log code to check its configuration and/or >> rewrite the log file for log rotation. > > You could use something like > > $SIG{USR2} = sub { > kill 'USR1', $$; > # ... now trigger your other logging system ... > }; > > Log::Log4perl->init_and_watch("l4p.conf", 'USR1'); > > which uses a user-defined signal handler listening to USR2. You can > add whatever other logic you need to it. When triggered, it also forwards > the signal to Log4perl's signal handler, which listens to USR1. > > Good enough? I was hoping for a solution that didn't burn two signals. I'm already using the most obvious signals: HUP, USR1, USR2, KILL, QUIT, etc... so I'm not exactly overflowing with extra signals. :o) -- seth /\ sethdaniel.org |