2
votes

This is going to be a quite broad question, and any suggestions, examples, links are very welcome!

I'm looking for a good way to log my users session, and actions on the site up to a certain point.

The site in question is a site for doing bookings. The users start with doing a search, doing a few steps of data gathering and selections and end up with a booking.

So what I need to implement is some kind of logging of the current session variables at each step the user takes. And perhaps some other valid information. Logging should preferably be done to the a database.

At the end i would like to associate all these session with a booking reference. The goal is to later if something goes wrong with the booking or we need to investigate a situation have all information we need.

I understand log4net is a popular choice for logging, and used it a bit myself for simple purposes, but can not find any good examples regarding my situation.

This should be a common situation, i'm curious how others do it.

1

1 Answers

1
votes

The way I've set this up sometime is to create two tables. One holds a row per session, with some session data (id, timestamp, ip, username (if any), other stuff) and a session_data table with a few rows per session, each row containing a sessionid (referencing the sessions table). a key (describing what is logged, like 'entryform', 'searchform', or 'orderform') and a XML field containing the serialized session state object.

Insert a row in the session table using global.asa's session_onstart. Insert rows in session_data as needed.

I used simple stored procedures, but I gather you can setup log4net to insert the row. One caveat: I did setup nlog one time to log the sessions and session data, but nlog (and I suppose log4net as well) logs on its on thread and does't always write to the database. I switched away from nlog for storing the critical session data (but used it for all other debug/logging/tracing purposes)