logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: log4perl multithread question: msg#00023

Subject: Re: log4perl multithread question
On Tue, 17 Oct 2006, Judd Taylor wrote:

> Looking at the Synchronized.pm file, it shows an arg to new(), %options,
> that is passed to IPC::Shareable tie() call. That would be an ideal
> place to stick on the Mode => '775' option.
>
> How can I define options to the constructor, if it's only init'd with a
> call to read a config file (i.e. how can I pass the options through the
> config file)?

You can pass the IPC::Shareable options hash this way:

    use Log::Log4perl qw(:easy);

    my $conf = q[
      log4perl.category                   = DEBUG, Syncer1

          # Screen appender 1 (unsynchronized)
      log4perl.appender.Screen           = Log::Log4perl::Appender::Screen
      log4perl.appender.Screen.layout    = SimpleLayout

          # Synchronizing appender, using the file appender above
      log4perl.appender.Syncer1          = Log::Log4perl::Appender::Synchronized
      log4perl.appender.Syncer1.appender = Screen
      log4perl.appender.Syncer1.options  = \
        sub { { create=>1, destroy=>1, mode=>0775 } }

      log4perl.appender.Syncer1.key      = l4p1

    ];

    Log::Log4perl->init(\$conf);
    DEBUG "foo!";


-- Mike

Mike Schilli
m@xxxxxxxxxxxxxxx
>
> Thanks,
>       Judd
>
> Ok, I've got the basic version of Log4perl::Appender::Synchronized
> running, but I'm running into a problem where the IPC::Shareable
> semaphores are created without group permissions.
>
> This causes apps starting with a different user to crash, as they don't
> have the correct permissions to be messing with those semaphores.
>
>
> On Wed, 2006-10-11 at 11:22 -0700, Mike Schilli wrote:
> > On Wed, 11 Oct 2006, Judd Taylor wrote:
> >
> > > I'm thinking about using log4perl as an alternative to my current object
> > > logging system, but I'm not sure how it will handle a situation where I
> > > need to append to a master logfile from several processes at the same
> > > time.
> >
> > Log::Log4perl::Appender::Synchronized to the rescue:
> >
> >     http://log4perl.sourceforge.net/d/Log/Log4perl/FAQ.html#23804
> >
> > -- Mike
> >
> > Mike Schilli
> > m@xxxxxxxxxxxxxxx
> >
> > > I need to append to this log from several programs, some of which are
> > > multi-threaded (fork) servers, as well as from several of the same
> > > programs at the same time. Avoiding conflicts where messages are lost,
> > > and atomicity are pretty critical. I also want to centralize the
> > > configuration for all clients in one place.
> > >
> > > Is this going to be easy with log4perl? What relevant docs should I be
> > > looking at first?
> > >
> > > I need something like this running pretty shortly, and my only
> > > alternative would be to write a forking Net::Server thing to handle the
> > > incoming requests. Getting something like that reliable will probably
> > > not be a quick thing...
> > >
> > > Thanks,
> > > Judd
> > >
> > >
> > >
> > >
> > > --
> > > ____________________________
> > > Judd Taylor
> > > Software Engineer
> > >
> > > Orbital Systems, Ltd.
> > > 8304 Esters Blvd, Suite 870
> > > Irving, TX 75063-2209
> > >
> > > judd.t@xxxxxxxxxxxxxxxxxx
> > > (469) 442-1767 x127
> > >
> > >
> > > -------------------------------------------------------------------------
> > > Using Tomcat but need to do more? Need to support web services, security?
> > > Get stuff done quickly with pre-integrated technology to make your job 
> > > easier
> > > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > > _______________________________________________
> > > log4perl-devel mailing list
> > > log4perl-devel@xxxxxxxxxxxxxxxxxxxxx
> > > https://lists.sourceforge.net/lists/listinfo/log4perl-devel
> > >
> >
> --
> ____________________________
> Judd Taylor
> Software Engineer
>
> Orbital Systems, Ltd.
> 8304 Esters Blvd, Suite 870
> Irving, TX 75063-2209
>
> judd.t@xxxxxxxxxxxxxxxxxx
> (469) 442-1767 x127
>
>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642


<Prev in Thread] Current Thread [Next in Thread>