Sunday 4 March 2012

XML schema for log4Net

Here’s a quick reminder about the XML schema for log4Net. I use this if I choose to put the log4Net configuration in a separate file and want Visual Studio intellisense to work.
Firstly, to get the log4Net configuration into a separate file I do something like this in the application configuration file (e.g. App.config):
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>

  <log4net configSource="Config\Log4Net.config"/>
In the Log4Net.config file I make sure the log4Net element is given a reference to the log4Net schema and and a namespace:
<log4net xsi:noNamespaceSchemaLocation=""
  <!-- log4Net configuration omitted -->

Hey presto! We now have intellisense for the log4Net configuration file.