首先:引用Log4net.dll,按照说明进行web.config配置
然后:在Global中写入:
protected void Application_Start(object sender, EventArgs e) { log4net.Config.XmlConfigurator.Configure(); }
然后:继续在Global中写入:
protected void Application_Error(object sender, EventArgs e) { ILog log = LogManager.GetLogger(typeof(Global)); log.Error("服务器发生异常:\r\n", Context.Error); }