in reply to File Locking in CGI programs

The very first time I used a database in a web app, it was to avoid all file locking problems. So, of course, with that background, this just screams to be a database problem.

Rather than logging to a file, insert into a logging table in your database. You already have a connection opened to it, just use it.

Note also that, for the purpose of logging, syslog is also a database. It solves all these same problems - you're communicating with a single server that interfaces to the file(s) transparently. (If that server is multi-process or multi-threaded, or even multi-machine, that can be solved by whoever writes the server, and you don't need to worry about it.)

I actually worry about very few file locking scenarios now ;-)

Replies are listed 'Best First'.
Re^2: File Locking in CGI programs
by perrin (Chancellor) on Jul 06, 2005 at 03:18 UTC
    Syslog is usually considered to be slower and less reliable than just appending to a local file yourself. It can drop messages sometimes.