简体   繁体   English

使用log4net版本2.0.3执行登录到数据库

[英]using log4net version 2.0.3 to perform logging into a database

We need a solution to do database logging with specifically version 2.0.3 of log4net. 我们需要一个解决方案来使用log4net的2.0.3版进行数据库日志记录。 Because this is an older version of log4net, I would like to know how to approach the issue of getting this version to play nicely with sql server 2012. 因为这是log4net的旧版本,所以我想知道如何解决让这个版本与sql server 2012很好地协作的问题。

  1. After going through this tutorial , I'd like to know whether it is necessary to use nhibernate to do this? 完成本教程后 ,我想知道是否有必要使用nhibernate来做到这一点?
  2. For 2.0.3, are there any other dependencies that would be necessary to do database logging? 对于2.0.3,是否还有其他依赖项来进行数据库日志记录?

No... NHibernate is overkill and would slow down your logging. 不...... NHibernate过度杀伤,会减慢您的日志记录速度。 You want logging to be fast. 您希望日志记录快速。 With log4net you should be able to directly log into a database table. 使用log4net,您应该能够直接登录数据库表。 No need to put an ORM between it. 无需在它之间放置ORM。

As your specification of SQL 2012, you do not need any other assemblies besides the .NET framework and log4net. 作为SQL 2012的规范,除了.NET框架和log4net之外,您不需要任何其他程序集。

NB the log4net documentation has an example of the needed configuration and table schema: https://logging.apache.org/log4net/release/config-examples.html 注意,log4net文档有一个所需配置和表模式的示例: https//logging.apache.org/log4net/release/config-examples.html

You can use the AdoNetAppender which already comes with log4net. 您可以使用已经附带log4net的AdoNetAppender You do not need anything else. 你不需要任何其他东西。 You can refer to THIS tutorial on how to implement it. 您可以参考教程了解如何实现它。

You also need to remember that log4net appenders are synchronous some operate on a batch of log events to improve performance however they all block the calling thread if too many log events are generated so I also highly recommend using an asynchronous forwarder. 您还需要记住,log4net appender是同步的,有些操作对一批日志事件进行操作以提高性能,但是如果生成了太多的日志事件,它们都会阻塞调用线程,因此我强烈建议使用异步转发器。 A very good implementation is explained HERE . 这里解释了一个非常好的实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM