界面:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
///
/// Error 的摘要说明
///

public class Error:Page
{
    public Error()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
        DataAccess.DataAccess.WebPath = Server.MapPath("");
    }
}
数据:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Web;
namespace DataAccess
{
    public class DataAccess
    {
///
        /// 错误日志
        ///

        ///
        public void SetError(Exception e)
        {
            string path = WebPath + " \\error";
            if (!Directory.Exists(path))
            {
                DirectoryInfo df = new DirectoryInfo(path);
                df.Create();
            }
            DateTime time = DateTime.Now;
            path = path + " \\e" + time.Year + "年" + time.Month + "月" + time.Day + "日.txt";
            FileStream eFile = new FileStream(path, FileMode.Append, FileAccess.Write);
            StreamWriter eWrite = new StreamWriter(eFile, Encoding.UTF8);
            string eString = "类名:" + e.TargetSite.ReflectedType.Name + "  方法名:" + e.TargetSite.Name + "  时间:" + DateTime.Now;
            eWrite.WriteLine(eString);
            eString = e.Message;
            eWrite.WriteLine(eString);
            eWrite.WriteLine("**************************");
            eWrite.Close();
        }
}