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.
In reply to File Locking in CGI programs by enemyofthestate
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |