When web applications are published onto web or application server, whom ever the user accesses the application through web server, since it has its own directories structured gives perfect response.
Since web server has directories defined for each application separately, we can create separate directory named “Log” in application folder path.
This Log folder helps in holding the audit logged files.
Audit log files can be created/updated at many instants, few of them are like
1) User logged in time with user id.
2) User logged out time.
3) User transactions done in application between logged in and logged out time.
4) Any application errors or exceptions.
These audit log files are ordinary text files which we usually create.
.NET frame work provides a class for which we have to create an object and perform file write/update operations.
System.IO package consists of required classes.
TextWriter tw = new StreamWriter(File path);
tw.WriteLine(“User abcd has logged in into system at “+Date.now.ToString());
tw.Close();
We can define a generic function, that writes information to log file when and there required by calling that function.
Simillarly inorder to trace errors, we just call that generic function inside catch blocks. Logging class name, function name along with error in log file helps support team to find the error easily by looking into log file.
This process of logging information to a text file is very important , could be used in many projects may be with different business conditions.
No comments:
Post a Comment