日志管理类
class LogManager
{
string logFilePath=string.Empty;
string logFilePrefix=string.Empth;
public string LogFilePath
{
get
{
if(string.IsNullOrEmpth(logFilePath))
{
if(System.Web.HttpContext==null)
{
logFilePath =System.AppDomain.CurrentDomain.BaseDirectory;
}else
{
logFilePath =System.AppDomain.CurrentDomain.BaseDirectory+string.Format(@"log\{0}",System.DateTime.Now.ToString(""));
}
}
}
}
WriteLog(string logFile,string className,string message)
{
if(!System.IO.Directory.Exists(LogFilePaht))
{
CreateDirectory();
}
using(StreamWriter sw = File.AppendText(LogFilePath+LogFilePrefix+logFile+ "" + DateTime.Now.ToString()))
{
sw.WriteLine();
}
}
}
转载于:https://www.cnblogs.com/gotolovo/archive/2011/01/25/1944350.html