Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?
like image 774
Alex Gordon Avatar asked Feb 17 '26 00:02

Alex Gordon


2 Answers

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.

like image 156
MaYaN Avatar answered Feb 19 '26 13:02

MaYaN


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

like image 33
Niels V Avatar answered Feb 19 '26 14:02

Niels V



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!