/// <summary>
/// Append a line to the applicable log file
/// </summary>
/// <param name="logEntry">line to add to log</param>
public void LogAppend(string logEntry)
{
// use the timestamp captured when the object was created to identify the file
string fname = LogFilename(timestamp);
WebSettings ws = new WebSettings();
// create a full path to the target log file
string logpath = ws.Lookup("LogPath", HttpContext.Current.Server.MapPath("~/App_Data"));
logpath = Path.Combine(logpath, fname);
// append to the log file or create it if it doesn't exist
if (!File.Exists(logpath))
{
using (StreamWriter sw = File.CreateText(logpath))
{
sw.WriteLine(logEntry);
}
}
else
{
using (StreamWriter sw = File.AppendText(logpath))
{
sw.WriteLine(logEntry);
}
}
}