ASP.NET 日志路径
默认路径
protected void Button_StreamWrite_Click(object sender, EventArgs e)
{
StreamWriter sw = new StreamWriter(@"\xxx.log",true);
sw.WriteLine("Start");
sw.WriteLine("进行中ing...");
sw.WriteLine("End");
sw.Close();
}
写入的文件会在C盘下,true = 该文件存在,则追加内容,否则,创建New文件,并写入内容
指定当前服务所在物理路径
protected void Button_StreamWrite_Click(object sender, EventArgs e)
{
string appPath = HttpContext.Current.Server.MapPath(@"\log.txt");
StreamWriter sw = new StreamWriter(appPath,true);
sw.WriteLine("Start");
sw.WriteLine("进行中ing...");
sw.WriteLine("End");
sw.Close();
}
写入的文件在app的物理Path下,true = 该文件存在,则追加内容,否则,创建New文件,并写入内容