I followed this tutorial and was able to get both of the projects working with my instance of sql server 2012:
However, when I included HLogger project within my solution (instead of using it together with the sample project above), it did work.
The following is a code snippet that worked for me when running it from the provided sample project; however, when I added this library to my own solution, it did not work.
ILog log = log4net.LogManager.GetLogger("NHibernateLogging");
log.Error("Error!", new Exception("Exception123"));
log.Warn("Warning");
Nothing happened. Nothing was thrown. The database was not populated. I am using the same hibernate.cfg.xml file as the one provided (and worked in conjuncture with the "sample project"):
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name="connection.connection_string">
Server=------.net;database=mydb;user id=myuser;password=sdofjosidfjoijsf;persist security info=true;
</property>
<property name="dialect">
NHibernate.Dialect.MsSql2000Dialect
</property>
<property name="show_sql">
true
</property>
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
</session-factory>
</hibernate-configuration>
The only change was to the app.config file. It used to be:
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler,log4net-net-1.0" />
and now it is:
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
The reason for this is that I cannot have multiple versions of log4net in the same solution, and I do not have a choice on my current log4net version due to its capabilities with being able to log the version 2 of masstransit with msmq.
The projects in the codeproject site were created for .NET 3.5, whereas my solution is .net 4.5.
How do I diagnose the reason for not being able to log anything with log4net in a database?