Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

best way to log events?

Status
Not open for further replies.

SuaveRick

Programmer
Apr 12, 2004
142
CA
Hi there,

I'm doing a database here and would like to log which use does what. What would be the best way to do this do you think? Would a file be best or maybe have a log table in the database that gets update. What have you guys done for this? thanks!

Rick
 
If the site is hosted on IIS and you have the access to the machine, why not use the server logs? If you want it to look 'presentable' then use Analog to compile the server's logs into some nice charts and graphs. It's free and pretty easy to setup.

Just a suggestion.
 
that's pretty good! I might be able to use that. Is there any way that you can get the log file to show the data that's being used for a post action? I'd like to log what the user actually entered into the database if possible, that's the only other thing I'd be looking for in the log file. Thanks!
 
You don't say what type of Database you are using and I'm not familiar with all of what the server logs will tell you, but if you want to see what changes are made to records within the database, then a log table inside the db would be the most appropriate way(assuming the server log's don't tell you what happens specifically within database records).
You should be able to grab the userID from the server and then use methods consistent with the type of db(sqlserver or Access or whatever)to record changes made by users.
I personally wouldn't want to try and do this using ASP. Databases generally have very adequate internal methods to do this. Then if you wanted to see the changes from a page, you could use ASP to pull the data back out of the db and display it.
To be more specific, you would have to give us more info.

Paul
 
I'm using ASP pages here with IIS5.

I'll have to do some thing about what exactly I want to see, the server logs do pretty good, they show me which page was accessed, when, and by what IP address. So that tells me who accessed what and when... I just don't know if I want to see more WHAT they did. Thanks for the thoughts.
 
One option, if your thinking about doing logging on the database, would be to set up all of your INSERTs and UPDATEs as stored procedures. That way you could easily re-use the same data to insert recortds into a(some) log table(s). If you decided the data wasn't going to be used and wante to turn the funcitonality off you would simply comment out that code in your stored procedure. This also means you aren't adding the extra command cals to your ASP code (and also speeding up your code since stored procedures are generally faster in the first place).
Logging from that level means you could log just the action the user commits (INSERT or an UPDATE) down to a partial action (user created new record in blah table with id 43, user updated record 45 in blah table) all the way down to a full log (user inserted a record into blah with x data values, user updated record x with y values that were originally z).

I would suggest staying away from the last one unless you only need to monitor a single table or smallgroup of tables for either security or need absolute traceability/accountability (CM?? standards - forgot the number).

-T

barcode_1.gif
 
Those are good ideas Tarwn. I am going to have to do more detailed logging than just the asp default logs because the client wants to be able to see what records were modified. I could then purge the logs by date to keep the table size under control.

That'll be the way to do it for me I think.

Thanks all!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top