本文转自:http://www.cnblogs.com/chiyung/archive/2009/09/04/1560585.html

DEMO:/Files/chiyung/sample.rar
ASP.NET中使用Log4Net将日志写到Sqlite中,有可能需要增加访客IP或访问地址记录到数据库独立字段.
效果如下:
[转载]扩展Log4Net中的ILog实现自定义日志字段

建一个类库为:
log4net.Ext.Web

添加以下3个类:
IWebLog.cs
WebLogImpl.cs
WebLogManager.cs
代码大概这样,log4net里面有很详细的参考:
 message, Exception t);
    }
}

log4net的配置,ConnectionType需要根据数据库驱动配置正确,如果你使用的是其它SQLiteADO.NET驱动:
>

使用:
 Server.GetLastError().InnerException;
    WebLog.Error(Request.UserHostAddress, Request.Url.ToString(), exception.Message, exception);
}

protected void Page_Load(object sender, EventArgs e)
{
  
throw new Exception("the message.");
}

相关文章:

  • 2021-04-21
  • 2021-07-22
  • 2021-06-13
  • 2021-10-26
  • 2021-10-12
  • 2021-11-07
  • 2021-07-27
  • 2022-12-23
猜你喜欢
  • 2022-01-04
  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-19
相关资源
相似解决方案