After installing the Application Insights nuget package to an Umbraco solution, you’ll get this error:
A section using ‘configSource’ may contain no other attributes or elements
<ExamineLuceneIndexSets configSource="config\ExamineIndex.config” />
<log4net configSource="config\log4net.config”>
<root>
<level value="ALL” />
<appender-ref ref="aiAppender” />
Source File: \project\web.config
This happens because part of the Application Insights installation process adds a <log4net> section to web.config. Which would make sense, except Umbraco already has a <log4net> section in /config/log4net.config. So as you can imagine, the solution is to manually move everything its added into that file. Unfortunately you can’t just copy/paste the whole lot, but it’s not particularly complicated:
- Move <appender-ref ref="aiAppender” /> into the log4net.config file’s <root> node
- Move the <appender name="aiAppender” …> section underneath the existing appenders in log4net.config
- Back in web.config, change the <log4net> section back to what it was before.