enemyofthestate has asked for the wisdom of the Perl Monks concerning the following question:
I have a logging problem that is driving me buggy. I have a CGI program that receives XML from a customer, processes it, enters some of the information in an Oracle database, and returns an XML document to the customer. Each step along the way is logged to a buffer and written all at once as the program ends. Her eis how I write to the log:
# open for append open FILE, ">>$g_db_logfile"; # wait for lock flock (FILE,LOCK_EX); # once lock is granted seek to end, JIC seek (FILE,0,2); # print the string print FILE "$logstr\n"; # unlock file flock (FILE,LOCK_UN); # close file close FILE;
The problem is that when several processes are running the log may not be written for all of them. I know the orders are coming in -- I can see them in the DB -- but I don't always get the expected log entry. Any ideas what I am doing wrong?
This particuar program is running on Perl 5.6.0.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File Locking in CGI programs
by tmoertel (Chaplain) on Jul 06, 2005 at 04:19 UTC | |
|
Re: File Locking in CGI programs
by perrin (Chancellor) on Jul 06, 2005 at 01:04 UTC | |
by enemyofthestate (Monk) on Jul 06, 2005 at 01:16 UTC | |
by perrin (Chancellor) on Jul 06, 2005 at 02:22 UTC | |
by duff (Parson) on Jul 06, 2005 at 03:49 UTC | |
by enemyofthestate (Monk) on Jul 06, 2005 at 05:24 UTC | |
|
Re: File Locking in CGI programs
by chas (Priest) on Jul 06, 2005 at 01:10 UTC | |
|
Re: File Locking in CGI programs
by duff (Parson) on Jul 06, 2005 at 03:45 UTC | |
|
Re: File Locking in CGI programs
by Tanktalus (Canon) on Jul 06, 2005 at 02:58 UTC | |
by perrin (Chancellor) on Jul 06, 2005 at 03:18 UTC |