<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Adventures With .Net &#187; FluentNHibernate</title>
	<atom:link href="http://adventureswith.net/tag/fluentnhibernate/feed/" rel="self" type="application/rss+xml" />
	<link>http://adventureswith.net</link>
	<description>C# and the like</description>
	<lastBuildDate>Tue, 15 Nov 2011 15:34:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>NHibernate, IoC and removing that damn Log4Net dependency</title>
		<link>http://adventureswith.net/nhibernate-and-that-damn-log4net-dependancy/</link>
		<comments>http://adventureswith.net/nhibernate-and-that-damn-log4net-dependancy/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 12:00:41 +0000</pubDate>
		<dc:creator>Dann</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[FluentNHibernate]]></category>
		<category><![CDATA[Logging]]></category>
		<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://AdventuresWith.Net/?p=50</guid>
		<description><![CDATA[Ok, so Log4Net is not that bad. It is a very good logging system, etc… So how do you perform IoC with the NHibernate logger? Well, you can’t. Unless you are ready to HACK CODE. That’s the brilliant thing about &#8230; <a href="http://adventureswith.net/nhibernate-and-that-damn-log4net-dependancy/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<div class="rw-left"><div class="rw-ui-container rw-class-blog-post rw-urid-510"></div></div><p>Ok, so Log4Net is not that bad. It is a very good logging system, etc…</p>
<p>So how do you perform IoC with the NHibernate logger? Well, you can’t. Unless you are ready to HACK CODE.</p>
<p> That’s the brilliant thing about open source. Take it and modify until its the shade of green that suits you. </p>
<p><strong>The First Warning</strong></p>
<p>If you modify the DLL for NHibernate, then all associated DLL’s break.    <br />For me this means FluentNHibernate wont like you. So you will have to rebuild that too for the new NHibernate DLL.</p>
<p>According to the <a href="http://nhjira.koah.net/browse/NH-1554" target="_blank">bug report for exactly this issue</a>, in the future log4net will be removed as a dependency (yay). For the logger interface Commons.Logging has been “sort-of” chosen. Meaning: you should&#160; use the ILog interface from Commons.Logging for your Log interface! Make’s it a bit more future proof. </p>
<p><strong>What I did to have IoC : 2nd Warning&#160; &#8211; This is not a concise walkthrough</strong></p>
<ol>
<li>Download the source code of</li>
<ol>
<li><a href="http://sourceforge.net/projects/nhibernate/files/" target="_blank">NHibernate</a> – Under the Browse Files you will find a SRC version.</li>
<li><a href="http://github.com/jagregory/fluent-nhibernate" target="_blank">FluentNHibernate</a> – Download from GitHub</li>
<li><a href="http://sourceforge.net/projects/netcommon/files/" target="_blank">Commons.Logging</a>&#160;</li>
</ol>
<li>Create a new Interface called <strong>ILog that is inside the NHibernate project. </strong>This is because it will be used as an adapter for the Commons.Logging. It’s probably best to put under a smart namespace like NHibernate.Logging.ILog</li>
<li>Create a LogManager class that does the same thing as the log4net LogManger, but using the Commons.Logging assembly. I know this is vague, but my implementation wasn’t very good. The idea is that when NHibernate is called, the LogManager is setup using the Commons.Logging.ILog object that was returned by my&#160; IoC object&#160; factory. </li>
<li>Remove the References of log4net from the projects</li>
<li>Replace all namespaces of log4net with the namespace of your new Interface and LogManager (say NHibernate.Logging).</li>
<li>Remove all Log4Net residue, like Cfg calls and XML setup arguments. </li>
<li>Build and everything should be happy. </li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://adventureswith.net/nhibernate-and-that-damn-log4net-dependancy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

