How to remove warning: The ‘log4net’ element is not declared

So I’ve seen a lot of questions around this issue with generally the only resolution being: “It’s a warning, just ignore this”. Whilst it is safe to do this, for pedants like me there is a true resolution. There are a few places around the net to get this but (like a lot of issues I blog about) you often need to combine the advice. Here’s the true resolution:

  1. Download the (unofficial) log4net XML Schema Definition (XSD) from http://csharptest.net/downloads/schema/log4net.xsd
  2. The the XSD to your project somewhere e.g. your Resources folder (if you have one)
  3. Restart Visual Studio (this may not be needed but some places recommend)
  4. Open your Log4Net.config file (or other file containing your Log4Net definition)
  5. With your XML file select look in your top menu for XML:
    xml
    NOTE: This is only visible when your XML file is selected!
  6. Select XML -> Schemas and an XML Schemas window pops up
  7. Locate your log4net.xsd and in the Use column select “Use this schema”
  8. Click OK

Your issue should now be resolved! This will, of course, work for other XML and XSD combos and not just for Log4Net. Hopefully now nobody will have this issue as the solution is all resolved in one neat location 🙂

About Stephen Pickett


Stephen Pickett is a programmer, IT strategist, project manager, RightNow and telephony expert, information security specialist, all-round geek. He is currently Professional Services Director at Connect Assist, a social business that helps charities and public services improve quality, efficiency and customer engagement through the provision of helpline services and CRM systems.


Stephen is based in south Wales and attended Cardiff University to study Computer Science, in which he achieved a 2:1 grading. He has previously worked for Think Consulting Solutions, the leading voice on not-for-profit fundraising, Fujitsu Services and Sony Manufacturing UK as a software developer.


Stephen is the developer of ThinkTwit, a WordPress plugin that allows you to display multiple Twitter feeds within a blog.


8 thoughts on “How to remove warning: The ‘log4net’ element is not declared

  1. Did everything like you mentioned. And now i have 79 Messages (as before) plus 1 Warning more (“The ‘doc’ element is not declared.”)…

  2. Hi Reto,

    That probably means that you have a number of other issues to resolve. To be honest, you don’t really need to resolve this issue – if you are comfortable with it then you can ignore it. It’s a balance between having no warnings and spending a lot of time resolving issues that may not really exist. Good luck!

Leave a Reply