View Full Version : I want to create a log file on insert, update, delete
07-07-2011, 05:42 AM
I want to create a log file on insert, update, delete. Please help.
07-07-2011, 08:51 PM
You'll need to provide specifics, including, at the least:
What it is whose activity is to be logged;
How such activities are being effected; and,
Who effects such activities.
07-08-2011, 11:50 AM
I don't know what language you're using, so here are some general steps:
1. Create a file
2. Attempt to do one of those commands (insert, delete, update, etc.)
3. Right after that, create a conditional statement:
(a) If the insert, delete or update was successful, open the file you created and write to the file the information you want in it.
(b) If the command was unsuccessful, open the file and write that an error occurred, or write nothing if you prefer.
4. Close the file.
5. If you're running this through some sort of loop, start at Step 2 if you want to put all of these reports into the same file, or Step 1 if you want different files.
6. If you're looking for one general report, create a string variable and one or two numeric variables after Step 1. The string can be a verbal representation of what happen, one of the numeric variables can count the successes and the second numeric variable (if you chose to create one) can count the failures.
Hope that helps somewhat. You can use that logic with pretty much any programming language.
07-08-2011, 11:26 PM
Can we take it to mean that 'insert' is to a new document as 'update' is to an appended one?
What kind of files are they; and, what programs are being used to create/edit them?
Is this local or web based?
On the web, your server access logs have a record of every PUT, meaning you can glean all the creation/change dates and times of any file on the site.
Locally, well, you can glean what you can from Explorer or Finder, or whatever. An autologger would have to be a plugin to a program (like perhaps HTML-Kit), or it would have to be a TSR or service that would always be available when needed to respond. Definitely programmer territory. Not to mention firewall and antimalware literate. A program like that would definitely raise some flags for those services.
The success/failure part of the logging is a bit confusing. If an update or insertion failed to take place, how would one write to a failed file any new log info? And if a file is deleted, where is the record of its existence?
In any program nowadays, what is the probability you won't be able to save your work? This is the part about the failure I don't get, or the need to log it.
Please expound, and fill us in more on the application for this logging system? When you say "command" it sounds very low level, like a non-GUI program running in DOS, UNIX or LINUX. I'm definitely not clear here what it is you mean. Do, please expound.