<?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; ASP.Net</title>
	<atom:link href="http://adventureswith.net/category/asp-net/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>Asp.Net MVC3 Razor and RESX Localisations/Localizations</title>
		<link>http://adventureswith.net/asp-net-mvc3-razor-and-resx-localisationslocalizations/</link>
		<comments>http://adventureswith.net/asp-net-mvc3-razor-and-resx-localisationslocalizations/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 19:11:48 +0000</pubDate>
		<dc:creator>Dann</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[asp mvc]]></category>
		<category><![CDATA[localisation]]></category>
		<category><![CDATA[resx]]></category>

		<guid isPermaLink="false">http://adventureswith.net/?p=256</guid>
		<description><![CDATA[I was just applying for a small two week contract that was based on Localisation. This is the work I did to give myself a quick refresh. It reminded me on how well Asp.Net MVC3 works with RESX localisations. As &#8230; <a href="http://adventureswith.net/asp-net-mvc3-razor-and-resx-localisationslocalizations/">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-2570"></div></div><p><em>I was just applying for a small two week contract that was based on Localisation. This is the work I did to give myself a quick refresh. It reminded me on how well Asp.Net MVC3 works with RESX localisations.</em></p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/11/image4.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" align="right" src="http://adventureswith.net/wp-content/uploads/2011/11/image_thumb4.png" width="229" height="244"></a>As a start, you will need someway to change your Local Language quickly. My preferred choice is using the <a href="https://addons.mozilla.org/en-US/firefox/addon/quick-locale-switcher/">Quick Locale Switcher for Firefox</a> which is in the image. </p>
<p>I have (over the last few hours) built up a fully translated version of the default MVC3 project which is viewable at <a title="RESX Examples" href="http://resxstuff.adventureswith.net"><strong>http://resxstuff.adventureswith.net</strong></a> and is viewable as 2 languages available English (Which is default) and French (which is terribly translated BTW).</p>
<h2>Turn On The World – Enable Globalisation</h2>
<p>To enable globalisation, you will need to add this line to your web.config&nbsp; in the &lt;system.web&gt;&lt;/system.web&gt; section:</p>
<pre class="brush: xhtml; toolbar: false">&lt;globalization uiCulture="auto" culture="auto"/&gt;</pre>
<h2>Add the RESX files; and let the class be seen</h2>
<p>If you are coming from Web Forms, note that for MVC you DO NOT HAVE TO (and perhaps should not) add your RESX to App_GlobalResourses or even App_LocalResources.</p>
<p>Just add them wherever you want and they can still be used, but only if you do the following:</p>
<ul>
<li>When you add<span id="more-256"></span>a new RESX, Change the Access Modifier to Public </li>
</ul>
<p>Otherwise you will be wondering why your resources don’t show up.</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/11/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/11/image_thumb.png" width="709" height="380"></a></p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/11/image3.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" align="left" src="http://adventureswith.net/wp-content/uploads/2011/11/image_thumb3.png" width="153" height="176"></a>I followed the advice given by a few others to use the “RESX to a View” method, where you mimic the View folder structure within the Resources folder; as seen in the picture.</p>
<p>This usually means it is fairly easy to find the right file for the string that you want to change in a hurry.</p>
<p>&nbsp;</p>
<h2>Views – Changing out the text</h2>
<p>I went through all the views and changed every “message to the user” into a string resource in a RESX file.</p>
<p>All the <strong>Html.LabelFor </strong>calls were replaced with resources calls<br />e.g. <strong>@Html.LabelFor (x =&gt; x.Username) </strong>became<strong> @Resources.Account.Register.Username</strong></p>
<p>All boilerplate text was replaced with Resources e.g. “Login was unsuccessful. Please correct the errors and try again.” was pulled out of <em>LogOn.cshtml</em> and moved to <em>Resources.Account.LogOn.Login_Unsuccessful</em></p>
<pre>@Html.ValidationSummary(true, Resources.Account.LogOn.Login_Unsuccessful)</pre>
<h2>Controllers – Fixing up user messages</h2>
<p>Essentially controllers are the same deal as the views. Take the static text, place it in a RESX file where it makes sense.</p>
<p>I used the files related to the views that were to be returned e.g. If an action method returned the Logon view, then I used the Logon.resx file for that text.</p>
<pre class="brush: c-sharp; toolbar: false">using Resources;

....
....
....
[HttpPost]
       public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }

       private static string ErrorCodeToString(MembershipCreateStatus createStatus)
        {
            // See http://go.microsoft.com/fwlink/?LinkID=177550 for
            // a full list of status codes.
            switch (createStatus)
            {
                case MembershipCreateStatus.DuplicateUserName:
                    return ErrorStrings.Username_Exists;  //these are the resource strings
                case MembershipCreateStatus.DuplicateEmail:
                    return ErrorStrings.Email_Exists;
                case MembershipCreateStatus.InvalidPassword:
                    return ErrorStrings.Invalid_Password;
                case MembershipCreateStatus.InvalidEmail:
                    return ErrorStrings.Invalid_Email;
                case MembershipCreateStatus.InvalidAnswer:
                    return ErrorStrings.Invalid_Answer;
                case MembershipCreateStatus.InvalidQuestion:
                    return ErrorStrings.Invalid_Question;
                case MembershipCreateStatus.InvalidUserName:
                    return ErrorStrings.Invalid_Username;
                case MembershipCreateStatus.ProviderError:
                    return ErrorStrings.Provider_Error;
                case MembershipCreateStatus.UserRejected:
                    return ErrorStrings.User_Rejected;
                default:
                    return ErrorStrings.Default_Error;
            }
        }
</pre>
<h2>Models &amp; Validation</h2>
<p>The only tricky part is this one. And it’s not even that tricky.</p>
<p>Instead of where you would normally put <em>ErrorMessage=”Something bad happened here”</em>, you would instead point it the RESX files.</p>
<p>All of the Validation attributes have the Properties <em>ErrorMessageResourceType</em> and <em>ErrorMessageResourceName</em> which are explained as follows:</p>
<ul>
<li>ErrorMessageResourceType – Points to the resource file type
<li>ErrorMessageResourceName – Points to the KEY within that resource file </li>
</ul>
<p>It is sad that the key is not strongly typed, like in the rest of the code; this is the annoying nature of attributes.</p>
<p>So here we have the example of a model with resource friendly validation:</p>
<pre class="brush: c-sharp; toolbar: false">public class LogOnModel     {      

[Required(ErrorMessageResourceType = typeof(ErrorStrings), ErrorMessageResourceName = "Required")]
public string UserName { get; set; }         

[Required(ErrorMessageResourceType = typeof(ErrorStrings), ErrorMessageResourceName = "Required")]
[DataType(DataType.Password)]
public string Password { get; set; }  

}</pre>
<h2>RESX &#8211; Adding more languages</h2>
<p>So now you have all the files in place to use the RESX files that have been created as you went along.</p>
<p>Adding RESX files for other languages is easy. Just copy, paste, rename and it works.</p>
<p>The naming convention is as follows (from lowest to highest priority):</p>
<ul>
<li>Default &#8211; mytranslation.resx
<li>Language &#8211; mytranslation.en.resx&nbsp; or mytranslation.fr.resx
<li>Regional &#8211; mytranslation.en-GB.resx or mytranslation.en-US.resx </li>
</ul>
<p>So how do you create these for more languages? Luckily there is a fantastic free opensource tool that is available. <a href="http://resxtranslator.codeplex.com/">ResxTranslator from Codeplex</a> is able to read all your RESX files in the project and help you out by creating the other languages.</p>
<p>After they are created, just include them in the project.</p>
<p><em>Just a note</em> that I haven’t been able to create another language from inside ResxTranslator, by which I mean add a language that doesn’t already exist somewhere in the resx files already.</p>
<p>First, I have to first create a file with the language in the filename, as shown above, for it to show up as an option in the “Add Language” tool. But once I have added a language/dialect for one RESX, it is available for all files. Maybe I am missing something here.</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/11/image2.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/11/image_thumb2.png" width="626" height="372"></a></p>
<h2>Further Reading</h2>
<p>Nadeem Afana &#8211; Internationalising MVC3<br /><a href="http://afana.me/post/aspnet-mvc-internationalization.aspx">http://afana.me/post/aspnet-mvc-internationalization.aspx</a></p>
<p><span style="font-size: small"><font size="3">K. Scott Allen &#8211; Resource Files and ASP.NET MVC Projects</font></span><span style="font-size: small"><br /></span><a href="http://odetocode.com/Blogs/scott/archive/2009/07/16/resource-files-and-asp-net-mvc-projects.aspx"><span style="font-size: small"><font size="3">http://odetocode.com/Blogs/scott/archive/2009/07/16/resource-files-and-asp-net-mvc-projects.aspx</font></span></a></p>
]]></content:encoded>
			<wfw:commentRss>http://adventureswith.net/asp-net-mvc3-razor-and-resx-localisationslocalizations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Common.Logging with Glimpse and ASP.Net MVC</title>
		<link>http://adventureswith.net/using-common-logging-with-glimpse-and-asp-net-mvc/</link>
		<comments>http://adventureswith.net/using-common-logging-with-glimpse-and-asp-net-mvc/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 10:24:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[asp mvc]]></category>
		<category><![CDATA[glimpse]]></category>
		<category><![CDATA[nuget]]></category>
		<category><![CDATA[visual studio]]></category>

		<guid isPermaLink="false">http://adventureswith.net/using-common-logging-with-glimpse-and-asp-net-mvc/</guid>
		<description><![CDATA[Glimpse is an amazing tool (that comes available with Nuget in Visual Studio 2010 [included in the Tools Update]) that can hook into the System.Diagnostic.Trace (ewww) to display error messages on your client side browser. Like so: I don’t want &#8230; <a href="http://adventureswith.net/using-common-logging-with-glimpse-and-asp-net-mvc/">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-2360"></div></div><p><a href="http://nuget.org/List/Packages/Glimpse">Glimpse</a> is an amazing tool (that comes available with <a href="http://nuget.org/">Nuget</a> in Visual Studio 2010 [<a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=82cbd599-d29a-43e3-b78b-0f863d22811a&amp;displaylang=en">included in the Tools Update</a>]) that can hook into the System.Diagnostic.Trace (ewww) to display error messages on your client side browser. Like so:</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/04/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/04/image_thumb.png" width="543" height="327"></a></p>
<p><em>I don’t want to use System.Diagnostics as my Logging system</em>. I could use it on the side, but not as the core. This would be awful and much too rigid. The good thing is, I typically use Common.Logging in all my projects because of it’s way to tie ANY LOGGING SYSTEM into a single point then ship those events off to any other receiving system. The receiving system in this case, is&nbsp; of course, System.Diagnostics.Trace using the TraceLoggerFactoryAdapter</p>
<p><span style="text-decoration: underline">So to get to the point above this is what I did:</span></p>
<ol>
<li>Using Create a new MVC project in VS2010
<li>Nuget
<ol>
<li>Install-Package Glimpse
<li>Install-Package Common.Logging </li>
</ol>
<li>Add Common.Logging&nbsp; to the web config
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:ac4b2b10-3d7b-4171-9cb7-1428e06708a2" class="wlWriterEditableSmartContent">
<pre style=" width: 510px; height: 300px;background-color:White;overflow: auto;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #008000;">&lt;!--</span><span style="color: #008000;">...config sections... </span><span style="color: #008000;">--&gt;</span><span style="color: #000000;">
</span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">sectionGroup </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">=&quot;common&quot;</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
      </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">section </span><span style="color: #FF0000;">name</span><span style="color: #0000FF;">=&quot;logging&quot;</span><span style="color: #FF0000;"> type</span><span style="color: #0000FF;">=&quot;Common.Logging.ConfigurationSectionHandler, Common.Logging&quot;</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">sectionGroup</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;"> 

</span><span style="color: #008000;">&lt;!--</span><span style="color: #008000;">...configuration... </span><span style="color: #008000;">--&gt;</span><span style="color: #000000;">
</span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">common</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">logging</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
      </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">factoryAdapter </span><span style="color: #FF0000;">type</span><span style="color: #0000FF;">=&quot;Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e&quot;</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">arg </span><span style="color: #FF0000;">key</span><span style="color: #0000FF;">=&quot;level&quot;</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">=&quot;ALL&quot;</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">arg </span><span style="color: #FF0000;">key</span><span style="color: #0000FF;">=&quot;showLogName&quot;</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">=&quot;true&quot;</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">arg </span><span style="color: #FF0000;">key</span><span style="color: #0000FF;">=&quot;showDataTime&quot;</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">=&quot;true&quot;</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
        </span><span style="color: #0000FF;">&lt;</span><span style="color: #800000;">arg </span><span style="color: #FF0000;">key</span><span style="color: #0000FF;">=&quot;dateTimeFormat&quot;</span><span style="color: #FF0000;"> value</span><span style="color: #0000FF;">=&quot;yyyy/MM/dd HH:mm:ss:fff&quot;</span><span style="color: #FF0000;"> </span><span style="color: #0000FF;">/&gt;</span><span style="color: #000000;">
      </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">factoryAdapter</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
    </span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">logging</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
</span><span style="color: #0000FF;">&lt;/</span><span style="color: #800000;">common</span><span style="color: #0000FF;">&gt;</span><span style="color: #000000;">
</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<li>Add some “problems”<a href="http://adventureswith.net/wp-content/uploads/2011/04/image1.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/04/image_thumb1.png" width="469" height="337"></a>
<li>Run the project and go to http://[your project url]/Gimpse/Configthen click “Turn Glimpse On”. Don’t be surprised that nothing happens.
<p><a href="http://adventureswith.net/wp-content/uploads/2011/04/image2.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/04/image_thumb2.png" width="438" height="431"></a></p>
<li>Go to your main page http://[your project url]/ – See the icon in the right hand corner? Click that.<br /><a href="http://adventureswith.net/wp-content/uploads/2011/04/image3.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/04/image_thumb3.png" width="451" height="257"></a>
<li>Look at those errors! </li>
</ol>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/04/image4.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/04/image_thumb4.png" width="500" height="302"></a></p>
<h2><span style="color: #000000">Conclusion?</span></h2>
<p>Amazing! The guys who made Glimpse deserve some sort of medal!</p>
]]></content:encoded>
			<wfw:commentRss>http://adventureswith.net/using-common-logging-with-glimpse-and-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AWStats on IIS7 (in less steps than the closest cup of coffee. Well almost. )</title>
		<link>http://adventureswith.net/awstats-on-iis7-in-less-steps-than-the-closest-cup-of-coffee-well-almost/</link>
		<comments>http://adventureswith.net/awstats-on-iis7-in-less-steps-than-the-closest-cup-of-coffee-well-almost/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 10:27:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[awstats]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[iis7]]></category>

		<guid isPermaLink="false">http://adventureswith.net/awstats-on-iis7-in-less-steps-than-the-closest-cup-of-coffee-well-almost/</guid>
		<description><![CDATA[So, you want AWStats on IIS7?&#160; This doesn’t require a restart of IIS, so it can be done in place with no issues. For IIS6, you will need to look elsewhere sorry. I’m also sorry you still have to deal &#8230; <a href="http://adventureswith.net/awstats-on-iis7-in-less-steps-than-the-closest-cup-of-coffee-well-almost/">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-2200"></div></div><p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image22.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb21.png" width="188" height="143" /></a></p>
<p>So, you want AWStats on IIS7?&#160; This doesn’t require a restart of IIS, so it can be done in place with no issues.</p>
<p>For IIS6, you will need to look elsewhere sorry. I’m also sorry you still have to deal with IIS6.</p>
<h3>The 2 Required Files</h3>
<li>ActiveState ActivePerl &#8211; <a title="http://www.activestate.com/activeperl" href="http://www.activestate.com/activeperl">http://www.activestate.com/activeperl</a> </li>
<li>AWStats Installer (<a href="http://prdownloads.sourceforge.net/awstats/awstats-7.0.exe">awstats-7.0.exe</a>)&#160; <a title="http://awstats.sourceforge.net/#DOWNLOAD" href="http://awstats.sourceforge.net/#DOWNLOAD">http://awstats.sourceforge.net/#DOWNLOAD</a> </li>
<li>
<h3>Installing ActivePerl</h3>
<p>&#160;</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image23.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb22.png" width="362" height="280" /></a></p>
<p><span id="more-219"></span><!-- more -->
<p>Accept the agreements, etc.. until you come to the Custom Setup screen</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image24.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb23.png" width="368" height="285" /></a></p>
<p>I have removed the Docs and the Examples. </p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image25.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb24.png" width="359" height="278" /></a></p>
<p>I have unticked the create IIS virtual directory as it’s not needed. </p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image26.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb25.png" width="360" height="278" /></a></p>
<p>Click Install.      <br /><font color="#ff0000">This is important: </font>When it has finished installing, LOG OUT of (or even better, reboot if you can) the system.       <br /><em>Logging out and back in will allow the system to pick up the new PATH that was modified by the ActivePerl install. </em></p>
<h3>Installing AWStats</h3>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image27.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb26.png" width="348" height="268" /></a></p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image28.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb27.png" width="348" height="268" /></a></p>
<p>Use the default directory, and click Install</p>
<p><font color="#ff0000">If you get an message stating that no Perl is detected:        <br /></font>Make sure you installed ActivePerl, and       <br />Log out and log in again, or       <br />Restart the machine </p>
<p>You will be presented with this; a command prompt. This is going to set up your default config file for your domain. </p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image29.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb28.png" width="377" height="189" /></a></p>
<p>It will try to detect Apache, but you don’t want that. </p>
<p>So type &quot;none”</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image30.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb29.png" width="371" height="186" /></a></p>
<p>It is asking you to create a new config file. </p>
<p>Type “y”</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image31.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb30.png" width="369" height="185" /></a></p>
<p>Enter in your domain name e.g. mydomain.com </p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image32.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb31.png" width="363" height="182" /></a></p>
<p>The config still needs to be set up properly, but for now we will create the website and the config after that.</p>
<p>&#160;</p>
<h3>Creating an IIS7 site</h3>
<p>Create a new site through INetMgr (the standard IIS manager)</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image33.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb32.png" width="383" height="372" /></a></p>
<p>I have un-ticked “start web site immediately”, but this may not be important. You will have to restart this site once it is configured properly. </p>
<p>Your settings can be different to these, but I have changed the default port to a random port (e.g. 1388) so this site is neither running as the default site, nor visible to the public as our firewall blocks this port.</p>
<p>&#160;</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image34.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb33.png" width="361" height="315" /></a></p>
<p>For this website (awstats), go to the “Handler Mappings”</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image35.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb34.png" width="228" height="215" /></a></p>
<p>Click “Add Module Mapping”.</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image36.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb35.png" width="349" height="302" /></a></p>
<p>Set it up as I have here:</p>
<p>Request Path: *.pl      <br />Module: IsapiModule       <br />Executable: C:\Perl\bin\PerlEx30.dll       <br />Name: Perl</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image37.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb36.png" width="407" height="167" /></a></p>
<p>Click Yes. You do want this to be allowed.</p>
<p><font color="#ff0000">64 bit Machines only:        <br /></font><font color="#ff0000">Make sure the site’s application pool is set to “Enable 32 Bit Applications”</font></p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image38.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb37.png" width="418" height="190" /></a></p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image39.png"><img style="background-image: none; border-right-width: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb38.png" width="201" height="93" /></a></p>
<p>Start up the website. You may need to start the application pool as well. </p>
<p>&#160;</p>
<h3>Moving the AWStats site into place</h3>
<p>Go to your AWStats install folder </p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image40.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb39.png" width="341" height="269" /></a></p>
<p>(mine is C:\Program Files (x86)\AWStats\wwwroot\ )</p>
<p>Copy these folders and files to your website folder (C:\inetpub\awstats)      </p>
<p>Go to your site in a browser to see if you are good to go:</p>
<p><a title="http://localhost:1388/cgi-bin/awstats.pl" href="http://localhost:1388/cgi-bin/awstats.pl">http://localhost:1388/cgi-bin/awstats.pl</a></p>
<p>You SHOULD get an error like this: </p>
<p><em>Error: Couldn&#8217;t open config file &quot;awstats.localhost.conf&quot; nor &quot;awstats.conf&quot;. Please read the documentation for directories where the configuration file should be located.</em> </p>
<p>If you do, be happy. We can move on. If you don’t, leave me a comment and I can try to help you out. </p>
<h3>Getting The Right Information From the Target Site</h3>
<p>You will need to get this information from your site that you wish to analyse:</p>
<p><u>1. The location of your log files</u></p>
<p>This is typically C:\inetpub\logs\LogFiles\W3SVC + the ID of the site. <em>Hint: The ID can be found in the INetMgr where the sites are listed.</em></p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image41.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb40.png" width="455" height="87" /></a></p>
<p><u>2. The name of your log files</u></p>
<p>Is the name u_ex or just ex? Maybe something different altogether.</p>
<p>e.g. u_ex101110.log</p>
<p><u>3. The format of your log files</u></p>
<p>In one of the log files that are in that folder, there is a line at the top you will need to copy:</p>
<p>#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken</p>
<h3>Setting up the Config and Linking to the Logs</h3>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image42.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb41.png" width="452" height="202" /></a></p>
<p>If you go to your website folder and have a look in the cgi-bin (C:\inetpub\awstats\cgi-bin) you will see a file called <em>awstats.mydomain.com.conf</em></p>
<p>Open this in your favourite text editor. You will need to change a few things:</p>
<p>LogFile=&quot;/var/log/httpd/mylog.log&quot;</p>
<p>will need to be replaced by the location of your log files for IIS7.</p>
<p>For “u_ex” names:</p>
<p>LogFile=”[PATH TO YOUR LOG FILES]\u_ex%YY-24%MM-24%DD-24.log”</p>
<p>The funny bit at the end is actually matching the log to the day (or more accurately, the previous day) the report runs. This means your report generation will need to be run at least every day. </p>
<p>You need to now set the format in which AWStats reads the files</p>
<p>Look for </p>
<p>LogFormat=1</p>
<p>And replace this with (using the example format taken from the log file I used)</p>
<p>LogFormat= “date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken”</p>
<p><em>NOTE: This is not the optimal log file format setup for AWStats.There is guide at <a href="http://sysadmingeek.com/articles/setting-up-awstats-on-windows-server-and-iis/">sysadmin geek</a> that can help with setting up optimally, with data transfer and referrer logs. To do this you will need to change the IIS log settings to provide different data. The reason I’m leaving that out for now is that I want this to be an easy setup. You can change things after you have got it working! </em></p>
<p>Find HostAliases and add in all aliases associated with this site.      <br />HostAliases=&quot;mydomain.com www.mydomain.com 127.0.0.1 localhost&quot;</p>
<p>From a security standpoint, there are some other settings you can play with, but they are not going to be looked at deeply here. Examples&#160; are :</p>
<p>AllowAccessFromWebToAuthenticatedUsersOnly=0      <br />AllowAccessFromWebToFollowingIPAddresses=&quot;&quot;       </p>
<h3>Running the first report generation</h3>
<p>It comes down to this.</p>
<p>Start up a command prompt, and run:</p>
<p>cd C:\inetpub\awstats\cgi-bin      <br />Perl awstats.pl –config:mydomain.com –update</p>
<p>This should start reading the Log files. When it is finished, go to the site in a browser:</p>
<p><a title="http://localhost:1388/cgi-bin/awstats.pl" href="http://localhost:1388/cgi-bin/awstats.pl?config=mydomain.com">http://localhost:1388/cgi-bin/awstats.pl?config=mydomain.com</a></p>
<p>If you see some numbers, congratulations!</p>
<h3>Setting up the Scheduled Task</h3>
<p>Now you have to run this every day, as the system does not automatically update.</p>
<p>I won’t go into detail here as there are many sites on setting up Scheduled Tasks in the Task Scheduler, but this is the screen shot of my settings:</p>
<p><a href="http://adventureswith.net/wp-content/uploads/2011/03/image44.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2011/03/image_thumb43.png" width="434" height="323" /></a></p>
<p>&#160;</p>
<h3>Conclusion &amp; Things You May Want To Do</h3>
<p>So that is how to set it up. Any queries and / or suggestions, let me know. </p>
<p><u>Do you want better stats with referrers and search engine queries?        <br /></u>Trying to set up better reporting by changing IIS Log settings. There is a good guide at <a href="http://sysadmingeek.com/articles/setting-up-awstats-on-windows-server-and-iis/">sysadmin geek</a> with all the settings.</p>
<p>&#160;</p>
<p><u>Do you want to parse old log files from months before?</u></p>
<p>There is a way to do this by specifying log files specifically, or by merging log files and then reading that merge specifically. This can be be done by specifying the file name in the config<font color="#000000">. You can use a tool included with awstats called </font><a href="http://awstats.sourceforge.net/docs/awstats_tools.html">“logresolvemerge.pl”</a> to merge the log files, which can take a while for multi gig log files. </p>
<p><em></em></p>
</li>
]]></content:encoded>
			<wfw:commentRss>http://adventureswith.net/awstats-on-iis7-in-less-steps-than-the-closest-cup-of-coffee-well-almost/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Converting MVC 2 RC to MVC 2 RTM</title>
		<link>http://adventureswith.net/converting-mvc-2-rc-to-mvc-2-rtm/</link>
		<comments>http://adventureswith.net/converting-mvc-2-rc-to-mvc-2-rtm/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 16:24:03 +0000</pubDate>
		<dc:creator>Dann</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[asp mvc]]></category>
		<category><![CDATA[conversion]]></category>

		<guid isPermaLink="false">http://AdventuresWith.Net/converting-mvc-2-rc-to-mvc-2-rtm/</guid>
		<description><![CDATA[Ok, this is more of a hack than a true conversion, but I haven&#8217;t noticed the difference… yet. Remember to back up what you’re not willing to lose! Remove your MVC project from your solution. Don’t delete, just remove. Then &#8230; <a href="http://adventureswith.net/converting-mvc-2-rc-to-mvc-2-rtm/">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-1100"></div></div><p>Ok, this is more of a hack than a true conversion, but I haven&#8217;t noticed the difference… yet.</p>
<p>Remember to back up what you’re not willing to lose! </p>
<ol>
<li>Remove your MVC project from your solution. Don’t delete, just remove. Then save all (Shift-Ctrl-S)</li>
<li>Edit your MVC project *.csproj file and change the ProjectTypeGuids to:     <br />&lt;ProjectTypeGuids&gt;{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}&lt;/ProjectTypeGuids&gt;<a href="http://adventureswith.net/wp-content/uploads/2010/03/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://adventureswith.net/wp-content/uploads/2010/03/image_thumb.png" width="531" height="166" /></a>      </li>
<li>Add your project back into your solution and save everything</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://adventureswith.net/converting-mvc-2-rc-to-mvc-2-rtm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Godaddy Hosting &#8211; Medium Trust vs Inversion of Control</title>
		<link>http://adventureswith.net/godaddy-hosting-medium-trust-vs-inversion-of-control/</link>
		<comments>http://adventureswith.net/godaddy-hosting-medium-trust-vs-inversion-of-control/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 01:32:29 +0000</pubDate>
		<dc:creator>Dann</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[godaddy]]></category>
		<category><![CDATA[IoC]]></category>
		<category><![CDATA[unity]]></category>

		<guid isPermaLink="false">http://AdventuresWith.Net/?p=54</guid>
		<description><![CDATA[Whatever I think of Godaddy, they haven’t caused me too much pain yet, just minor inconvenience. This time it’s my precious StructureMap. StructureMap, I like it and alot of people do, but it just won’t work under Medium Trust! So &#8230; <a href="http://adventureswith.net/godaddy-hosting-medium-trust-vs-inversion-of-control/">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-550"></div></div><p>Whatever I think of Godaddy, they haven’t caused me too much pain yet, just minor inconvenience. This time it’s my precious StructureMap.</p>
<p>StructureMap, I like it and alot of people do, but it just won’t work under Medium Trust! So it’s either time to change Hosts, or change IoC container. Pretty obvious which one is the easier choice here. </p>
<p><strong>So what choice do you have? Well not much. So the answer is:</strong></p>
<blockquote><p><a href="http://unity.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=18855#DownloadId=47882" target="_blank">Unity from Microsoft Patterns &amp; Practices</a>*</p>
</blockquote>
<p><font color="#777777">Here’s a <a href="http://download.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=unity&amp;DownloadId=47882&amp;FileTime=128697897350700000&amp;Build=16135" target="_blank">nice manual</a> to go with it. </font></p>
<p>And what’s not able to be run in medium / partial trust:</p>
<blockquote><p>Windsor Castle     <br />Spring.Net      <br />StructureMap</p>
</blockquote>
<p>There was someone who was explaining how to download and build Spring.Net to allow it to run under Medium Trust, but that seems pretty likely to cause issues when you hack code (try to ignore my NHibernate post when I say that). </p>
<p>It may be the same for the other 2, but off the bat, Unity wins.</p>
<p>*Caveat: Unity is restricted in what it can do when run without ReflectionPermission (which is what Medium Trust disallows), but typically this won’t affect much from the normal IoC behaviour.&#160; The restrictions are explained on this <a href="http://msdn.microsoft.com/en-us/library/dd203232.aspx" target="_blank">MSDN doc</a>, but it’s to do with internal and private constructors and properties. If it’s public you should be sweet. </p>
]]></content:encoded>
			<wfw:commentRss>http://adventureswith.net/godaddy-hosting-medium-trust-vs-inversion-of-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>

