Click here to Skip to main content
15,914,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
:confused:I want to create a logfile so that all events caused by the user to store items on a database are recorded. For instance:
Total records created
Number of records deleted
Date Changes
User Name
Table id

Please help me to create this file in C#.

[edit]Subject, tidy and rephrase - OriginalGriff[/edit]
Posted
Updated 20-Nov-10 22:09pm
v2
Comments
Sandeep Mewara 21-Nov-10 4:02am    
Wel, what kind of logging we are talking of here?
Text file? Event Viewer? 3rd party log support?

You need to decide what you are going to do with the database, and with the log file - if you are storing info on every action the user takes with the database, then the log file is quickly going to get bigger than the database itself!
You also need to decide why you are going to store this info - is it for an audit trail? Who is going to view it?
Additionally, where are you going to store the log? If it is on the users local machine, then you will have permissions issues, and log deletion issues. If it is on your server, then you have the problem of multiple user access, and a LOT of bandwidth use.
You may find the best thing to do is to add the log as a database table, or as a separate database.
Have a think, and look at Google - see what others have done.
 
Share this answer
 
Because you did not specify what kind of user, I assume this is any user that changes the database entities.
In this case such log file already exists: it is called data log file :-)
Any database has it together with a data file. You don't need to re-invent a wheel.
If you are talking about an application user, then you have to decide what you want to log, write log procedure, and call it in the procedures which are involved in changing your database.
You must be more specific when you define the question.

Good luck.
 
Share this answer
 
 
Share this answer
 
XML
You can use the Trace Switches that traces each and every action that performed in an application.To Trace that your action acquired in your application.
Use The Following Link --><a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.trace(VS.71).aspx">a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.trace(VS.</a>[<a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.trace(VS.71).aspx" target="_blank" title="New Window">^</a>]
 
Share this answer
 
maybe your database has a build in logging feature? ;P
 
Share this answer
 
Yeap... the builtin logging feature sounds like the best idea to me too...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900