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
  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:
    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 and architect, project manager and business analyst, Oracle Service Cloud and telephony expert, information security specialist, all-round geek. He is currently Technical 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, a 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.

14 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!

  3. Was not working until I looked at some of the sample config files
    My log4netDefault.config file I added this to the top

    and because I use this schema for my layout

    –I got a warning it about this layout so:
    In log4net.xsd

    Find this line !

    Add this line after

    As if by Magic — Zero errors – Zero Warnings (250,000 line project 🙂
    So call me clinical but I hate warnings

  4. ok my last post has the XML lines removed,

    Basically a few mods to my config file and the downloaded xsd file and

    As if by Magic — Zero errors – Zero Warnings (250,000 line project Wooohooo)
    So call me clinical but I hate warnings

    Thank you very much for your Blog !

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.