You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by John Gateley <ga...@jriver.com> on 2008/04/15 23:03:51 UTC

modperl and syslog, strange behavior

Hi Y'all,

I'm new to mod_perl, please forgive me if this is already well known
info.

I have several different web scripts like:

if($UseLog) {
  Sys::Syslog::setlogsock('unix');
  openlog("$WebScriptName", 'pid', 'daemon');
  syslog('info', "$WebScriptName starting");
}
...
syslog('info', "Message"); # Actually buried in a subroutine
...

Originally, if $UseLog was false for an invocation of the script,
the "Message" would not appear in the syslog.

When I turned on mod_perl, sometimes I found "Message" appearing,
but under a different script's name.

So: mod_perl is somehow saving the socket state between runs of
webscripts, right?

Is it doing what it is supposed to be doing? Is there anything
wrong with what I am doing?

And most important - is there any other area that has the same or
similar behavior?

Thanks,

j

-- 
John Gateley <ga...@jriver.com>

Re: modperl and syslog, strange behavior

Posted by Perrin Harkins <pe...@elem.com>.
On Tue, Apr 15, 2008 at 5:03 PM, John Gateley <ga...@jriver.com> wrote:
>  if($UseLog) {
>   Sys::Syslog::setlogsock('unix');
>   openlog("$WebScriptName", 'pid', 'daemon');
>   syslog('info', "$WebScriptName starting");
>  }
>  ...
>  syslog('info', "Message"); # Actually buried in a subroutine
>  ...
>
>  Originally, if $UseLog was false for an invocation of the script,
>  the "Message" would not appear in the syslog.
>
>  When I turned on mod_perl, sometimes I found "Message" appearing,
>  but under a different script's name.
>
>  So: mod_perl is somehow saving the socket state between runs of
>  webscripts, right?

The perl interpreter stays around, so yes, a socket opened will stay
open until you close it.  That may or not be the problem.  I'd suggest
you try closing it at the end of each request (maybe with a cleanup
handler) and see if that makes the problem go away.

- Perrin