Logging user actions on ASP.NET site?

2019-08-16 07:09发布

What I want is system which is logging methods called by users and their returning values if they have. For example a user logs in and he/she is surfing on my web app. then naturally he/she clicks on somethings and so he/she fires up some event method whatever then my log system must log this method name and time stamp combined with user login name or id into database.

So how can I do that in asp.net.

2条回答
男人必须洒脱
2楼-- · 2019-08-16 08:00

Well, the simplest way is just to add all the logging statements to your code, using a logging framework such as Log4Net. If you want a more automatic way of doing this, you might want to look into PostSharp so that you could just decorate the appropriate methods with an attribute - but that's certainly more complex, and probably only worth it if you have a lot of events to log.

查看更多
Bombasti
3楼-- · 2019-08-16 08:00

you can attach your write logic class to events triggered from parts of code. using events driven architecture is a good pattern

查看更多
登录 后发表回答