Log4perl in CGI scipts

Log4perl in CGI scipts

am 02.11.2007 15:05:12 von Mark Knoop

Hi

Is it there any reason not to use Log4perl in a normal CGI environment?

Is there anything one should bear in mind when doing so?

Is there any issue with having many calls to a CGI script logging to a
single file?

Thanks
Mark





_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: Log4perl in CGI scipts

am 02.11.2007 15:46:01 von Wayne Simmons

Mark,

I'm unfamiliar with Log4perl specifically but I can tell you from recent
experience: YES there is an issue with multiple threads trying to write to a
single file. However, this depends on the load the server will bear, as
well has how many times you write to the file etc. We had a CGI that was
taking on average 50seconds to execute when running multiple copies on the
web server. Then we turned off logging and it dropped to about 3seconds.

If a file is open for write by another process and the current process tries
to open it, the current process will block waiting for the resource to free
up. Even if you only open, write one line, and close the file (as my script
did) the likelihood of a resource conflict is high, and increases each time
you add another call to the script (which executes under a different thread
in apache).

If you're using mod perl then you can use warn as normal and it will issue
statements to the httpd error_log. I'm considering trying to find out if I
can tap into the syslog for more detailed logging, you might do the same.

-Wayne Simmons

--
Software Engineer
InterSystems USA, Inc.
303-858-1000


-----Original Message-----
From: activeperl-bounces@listserv.ActiveState.com
[mailto:activeperl-bounces@listserv.ActiveState.com] On Behalf Of Mark Knoop
Sent: Friday, November 02, 2007 8:05 AM
To: activeperl@listserv.ActiveState.com
Subject: Log4perl in CGI scipts

Hi

Is it there any reason not to use Log4perl in a normal CGI environment?

Is there anything one should bear in mind when doing so?

Is there any issue with having many calls to a CGI script logging to a
single file?

Thanks
Mark





_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: Log4perl in CGI scipts

am 02.11.2007 19:43:48 von Wayne Simmons

-----Original Message-----
From: Bill Luebkert [mailto:dbecoll@gmail.com]
Sent: Friday, November 02, 2007 9:20 AM
To: Wayne Simmons
Cc: 'Mark Knoop'; activeperl@listserv.ActiveState.com
Subject: Re: Log4perl in CGI scipts

Bill Luebkert wrote:
>On UNIX, I would think there would be no problem writing to a log file
>as long as you were in append mode (at least that's what I recollect from
>my UNIX programming days).


Well this function:

if ( !open (X, ">>", "$conf{LOG}{DIRECTORY}/$conf{LOG}{FILE}") )
{
warn ("can't open log file");
return;
}
print X scalar(localtime), "($LOG_LVL_PREFIX[$lvl]) $msg\n";
close (X);

was what was causing the hold up on linux. Perhaps because the open request
was coming from multiple threads of the same process it was treated
differently, because that is append mode, I believe.

I know that I was surprised by this result too, I had the feeling that there
are usually not this kind of problems in UNIX.

-Wayne Simmons.

--
Software Engineer
InterSystems USA, Inc.
303-858-1000




_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs