PDA

View Full Version : Spring+NHibernate+Log4Net


laloivol
11-21-2006, 08:11 PM
When trying to build a web app using Spring .NET, NHibernate and Log4net and the .NET framework 2.0 ,a big problem came across. I found an issue with NHibernate (here's another post 'bout that http://forum.hibernate.org/viewtopic.php?p=2330330#2330330).
So, I downloaded the last Beta 2 version of NHibernate, but now log4net doesn't run because NHibernate and Spring use different versions of log4net: NHibernate uses log4net 1.2.10 and Spring uses 1.2.9... so, I thought it would be a good idea to recompile Spring using log4net 1.2.10, I downloaded the lastest source code, but did not find the Spring.Web assembly. Then I downloaded the latest nightly snapshot build and found that my assembly was right back, I recompiled, and when everything seemed to be ok, got this exception:

Could not load type 'Spring.Context.Support.WebSupportModule' from assembly 'Spring.Web'.



I looked for the WebSupportModule but I couldn't find it. Now I don't know what to do. Any ideas please???

Mark Pollack
11-21-2006, 10:07 PM
Hi,
I've introduced a 'Common.Logging' library which removes the dependency of Spring on log4net. If you get the latest build, Common.Logging.dll is included. The Hibernate 1.1 integration modules has Common.Logging.Log4Net129.dll and the Hibernate 1.2 module has Common.Logging.Log4Net for log4net 1.2.10. The need for two is because log4net changed the key they use to sign their assemblies from 1.2.9 to 1.2.10.

As for the WebSupportModule - it is there - I'm not sure why you are not finding it. It is in Spring.Web.

You can configure it to use log4net 1.2.9 or 1.2.10 as shown below.

<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>

<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter , Common.Logging.Log4Net129">
<!-- choices are INLINE, FILE, FILE-WATCH, EXTERNAL-->
<!-- otherwise BasicConfigurer.Configure is used -->
<!-- log4net configuration file is specified with key configFile-->
<arg key="configType" value="EXTERNAL" />
</factoryAdapter>
</logging>
</common>

Hope this helps...I'll be writing better docs and packaging this better in the coming week.

Mark

Mark Pollack
01-01-2007, 09:54 PM
Hi,

Documentation for common logging can be found here (http://www.springframework.net/doc-latest/reference/html/ch13.html).

Cheers,
Mark

ika
01-22-2007, 09:12 PM
Just for the record; I had problems with the WebSupportModule too (that's why I found this thread...). It turned out that I used wrong ASP.Net-version.

ika