This post is more of an FYI to myself than anything. There are a short number of steps which you need to take to debug Log4net issues when Log4net is not working. I always forget them and I am sick of navigating to the same StackOverflow question.

So, if the ADO.NET appender Log4net is not writing anything to the relevant table in your database, you need to take a look at the internal debugging built into Log4net. It’s only really 2 things that you need to do – add an app setting and a trace listener. Follow these steps to do that:

add the following AppSetting to the AppSettings in your config file (Web.config or App.config as applicable):

There’s a neat trick in the Chrome Developer Tools which not too many people are aware of. Firstly, I’m just going to run through something you should already know. You can obtain the xPath value for an element in the page by:

selecting the element in the Elements tab of the chrome developer tools; and

right clicking on that Element and selecting copy XPath

That will copy the XPath value for that element into the clipboard. Really handy for things like the XPath selector in Selenium.

Sometimes, that XPath is not exactly the way you want to write it. For example, some XPath values will be more bullet-proof in terms of selecting an element because they may handle dynamically loaded elements better than the one which we extracted using the method above. (That’s perfect for the page in the state that it is in at that moment). But we may want to re-jig that XPath so that it will still find that element every day.

Here’s the neat trick. You can open the console and run XPath expressions against the page. The syntax is to simply using a lower case ‘x’ between the ‘$’ sign and the brackets: $x('xpath here')

I created a useful code snippet that I thought I would share. The shortcut is tm and the snippet outputs the following text, giving you the skeleton for a unit test:

[TestMethod]
public void TestMethod()
{
// Arrange
// Act
// Assert
}

You can download that snippet by clicking the following button:

Also, I got sick of typing mvcaction4 every time I wanted to scaffold out an Action Method. So I cracked open the snippet file for that snippet using the a text editor and changed the contents of the shortcut element to mac4. Much easier to type and very easy to remember as well!

On Wednesday night I delivered a presentation about MembershipReboot, a claims-aware authentication library for ASP.NET. Here are some links relevant to the content, in addition to the PowerPoint presentation which I used: