1

I am creating an app using mvc web api and I'm using log4net(for the first)

In my web.config I add these lines

<configuration>
    <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
    </configSections>
    <log4net debug="false">
        <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
            <param name="File" value="C:\Users\Ibrahim\Desktop\Ibrahim\logs\logs.log"/>
            <param name="AppendToFile" value="true"/>
            <layout type="log4net.Layout.PatternLayout">
                <param name="ConversionPattern" value="%d [%t] %-5p %c %m%n"/>
            </layout>
        </appender>
        <root>
            <level value="All"/>
            <appender-ref ref="LogFileAppender"/>
        </root>
    </log4net>
    //other configurations
</configuration>

but my web.config is showing me 21 messages stating

Could not find schema information for the element 'log4net'. {my projectname} {my path} using log4netunitydapp{my projectname}\Web.config 75

after searching around the net i find THIS question related,

i tried some answers like

Go to the "XML" menu and select "Create Schema". This action should create a new file called "app.xsd" or "web.xsd".

The error was not appearing after this but the log file was not able to save either,

Then I switched to solution number 2

Right-click on the project icon in Solution Explorer and choose "Properties". Go to the "Application" tab and choose an earlier .NET target framework. Save changes. Go to the "Application" tab and choose the initial .NET target framework. Save changes => problem solved!

I even Changed My .Net framework to 2 but the problem is still not solved

Then I switched to this solution

When this happened to me (out of nowhere) I was about to dive into the top answer above, and then I figured I'd close the project, close Visual Studio, and then re-open everything. Problem solved. VS bug?

and this didn't help either, what should be the possible solution for this?

Community
  • 1
  • 1
Hemanth Vatti
  • 85
  • 1
  • 8

0 Answers0