Best practices for logging user actions in production
- by anthonypliu
I was planning on logging a lot of different stuff in my production environment, things like when a user:
Logs In, Logs Off
Change Profile
Edit Account settings
Change password
...
etc
Is this a good practice to do on a production enviornment? Also what is a good way to log all this. I am currently using the following code block to log to:
public void LogMessageToFile(string msg)
{
System.IO.StreamWriter sw = System.IO.File.AppendText(
GetTempPath() + @"MyLogFile.txt");
try
{
string logLine = System.String.Format(
"{0:G}: {1}.", System.DateTime.Now, msg);
sw.WriteLine(logLine);
}
finally
{
sw.Close();
}
}
Will this be ok for production? My application is very new so im not expecting millions of users right away or anything, looking for the best practices to keeping track of actions on a website or if its even best practice to.