简体   繁体   中英

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. 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.

  1. After going through this tutorial , I'd like to know whether it is necessary to use nhibernate to do this?
  2. For 2.0.3, are there any other dependencies that would be necessary to do database logging?

No... NHibernate is overkill and would slow down your logging. You want logging to be fast. With log4net you should be able to directly log into a database table. No need to put an ORM between it.

As your specification of SQL 2012, you do not need any other assemblies besides the .NET framework and log4net.

NB the log4net documentation has an example of the needed configuration and table schema: https://logging.apache.org/log4net/release/config-examples.html

You can use the AdoNetAppender which already comes with log4net. 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. A very good implementation is explained HERE .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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