1

I´m doing a commercial app that will be used by many users. The users has to log in and there the system gets what forms can he access.

Now, I need to log every action he does. When I say every action, I mean every AMD (add - modify - delete) done in the entities. Also, I want to log what fields did he changed/added/deleted and their values. (Just in case, I´m using entity framework 4)

I was thinking of an implementation similar to a version control.

What I thought was to do this:

enter image description here

I´ll add a log entry everytime a user does a AMD in some important entities. In that log entry, I will have id_entity_type, which is related to the type of entity that I´m saving. (ex: Client, Loan, Banks, etc). Every type will be saved in Entity_type. I will have to check in C# which kind of entity I´m working with to look for the correct one. id_entity is the ID of that entity. id_action_type is what kind of action the user done (ex. "CREATE" / "UPDATE / "DELETE") id_user is related to the user. date_time to log the entry with a date and time. And here is the important thing:

Values, is a text with all the fields and values of the entity for that time. Here is an example:

ENTITY CLIENT:

  • name : John
  • last name : Doe
  • address : Oak st 123
  • city : Buenos Aires
  • country : Argentina

Then, in another log entry, another user updates the country to USA

  • name : John
  • last name : Doe
  • address : Oak st 123
  • city : Buenos Aires
  • country : USA

Then, when a User want to check the changes of an entity, he can see through a TextDiff (similar to a version controller) the changes in the entity through time.

I want to get some advice if this is a good way to achive this or not.

I know that database´s triggers can be use to save this log. I know too little about this, but I guess I will need a log table for every entity I have.

Please if somebody knows what is a good way to do this I will be great.

Andres
  • 2,729
  • 5
  • 29
  • 60
  • how many users are you using.? also how come you can't use the Event log or write your own log file which can get fairly big ..what type of things are you wanting to specifically log..? – MethodMan Jan 25 '13 at 02:22
  • What is the Event log? The type of things I want to log are AMD of every entity. To know what was done, who, when. It´s not suppose to have more than 10 users. I have only 3 users now. – Andres Jan 25 '13 at 02:28
  • you could write just a simple Database Logger or a TextFile Logger .. would be nice to see what you have tried in regards to how you are trying to implement .. btw the EventLog disregard I was thinking about if you were logging application events / errors .. most people use that when doing windows service application but you can use it for other things as well..for what you want limit yourself to something like Log4Net, Database Logging, or doing your own log streaming.. – MethodMan Jan 25 '13 at 02:35
  • I havent tried anything yet, thats why I was writting here. I thought of implementing that solution, but wanted to know if there are best solutions for my problem. I don´t know much about logging data, thats why I´m asking here. I just don´t want to lose a lot of time in something that could have been done in so much less time. – Andres Jan 25 '13 at 02:45
  • everything in regards to coding or designing should take time ..but in your case you should try to implement simple logging and if it doesn't fit your needs moving forward just change the code to log to a database.. but that's just what I would do.. I've done this for the Enterprise Web application at the Bank I was consulting for and had zero issues .. we had over 50,000 users.. – MethodMan Jan 25 '13 at 02:49
  • What do you mean by simple loggin? When you tell me about database logging you mean saving like this "INSERT INTO CLIENT ...." "UPDATE INTO CLIENTE..."? Just in case, the idea of logging is to be able to control what employees did. With your experties what do you think the best approch will be? Remember users here are only employees. This is a desktop winforms app. Thanks!! – Andres Jan 25 '13 at 02:56
  • Simple I mean creating a logfile.log or txt and yes to your Insert Into example – MethodMan Jan 25 '13 at 02:59
  • Yes, that can be done and will work fine. The only problem is how can that info can be of importance to the owner of the company. I mean, we know what an UPDATE, INSERT, DELETE does, but other people see that logs and does not know what that means. I do like the solution though. Do I have to use database users for this solution? How do I log in the file? Using triggers? If you can put me in the right direction I will be grateful :) – Andres Jan 25 '13 at 03:07
  • log4net -- lets you separate what you log from where you log it and lets you change it via configuration. Start simplly with rolling file logs – dbugger Jan 25 '13 at 03:09
  • @Andres although dbugger mentioned log4net, but may I suggest this [comparison](http://stackoverflow.com/questions/710863/log4net-vs-nlog) – Jake Berger Jan 25 '13 at 04:22
  • Ok guys, I will check that. I think DJ KRAZE was telling me to use database logging, which I think it will be better.. I mean, I just need to use triggers, and everytime a change is commited, it will write the query in the log. Right? This is not my field of knowledge, thats why I´m asking so many questions.. – Andres Jan 25 '13 at 13:38

0 Answers0