Logging...

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

Logging...

Post by swraman »

Hi,

Is it a bad idea to store frequently updated information in a file on a server?

The reason I want to use a file on the server and not a db is: I am working on a script that uses a pgsql database, and I want to store every query in which data is submitted to the server (ie. every query that adds info or updates the database). This would be for backup/transfer purposes.

should I just get to it and write a backup script that reads all the tables' rows' data and generates a backup sql file, or will this cheap workaround work? Is it bad for server load?

Thanks
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Logging...

Post by Chris Corbyn »

I'd be surprised if PgSQL doesn't already have a feature that does this for you, a bit like MySQL's binlog.

If PgSQL can handle replication within a cloud of DB servers then it will most likely track queries somewhere in this way.

EDIT | To directly answer your question, writing to files on disk is probably fine provided your code is well written. This is exactly what happens with most services that are running on UNIX-like systems (they write log entries to files in /var/log or wherever). You'll need to make sure the file is locked during write processes however.
Post Reply