Log4net with Entity Framework 5 and MVC4

笑着哭i 提交于 2019-12-05 12:02:45

Add this line to Global.asax.cs (in Application_Start()):

log4net.Config.XmlConfigurator.Configure();

Also, you can turn on log4net debugging to help you figure out what's going wrong by adding this line to your Web.config under <appSettings>:

Edit: The below had value="false", but should be value="true".

<add key="log4net.Internal.Debug" value="true"/>

Edit:

You can send log4net's internal debug logging to a file by adding the following to your Web.config (see the official explanation here):

  <system.diagnostics>
    <trace autoflush="true">
      <listeners>
        <add
            name="textWriterTraceListener"
            type="System.Diagnostics.TextWriterTraceListener"
            initializeData="C:\mylogdirectory\log4net_debug.txt" />
      </listeners>
    </trace>
  </system.diagnostics>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!