Log4Net works on Dev machine, fails when deployed to shared host (using same db/connstring)

匆匆过客 提交于 2019-11-28 09:29:57

In my experience, log4net usually swallows any internal errors, simply resulting in log statements that do not produce any results.

What you may want to try is enable log4net's internal logging. You can do this by adding the following to your appSettings section:

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

This sets the property LogLog.InternalDebugging to true. log4net will now log to the standard output and error streams and to configured trace listeners.

You can use the following configuration to capture any messages logged to tracing:

<system.diagnostics>
  <trace autoflush="false" indentsize="4">
    <listeners>
      <add name="myListener"
        type="System.Diagnostics.TextWriterTraceListener"
        initializeData="c:\TextWriterOutput.log" />
      <remove name="Default" />
    </listeners>
  </trace>
</system.diagnostics>

All messages logged by log4net internally will appear in TextWriterOutput.log. If you get a SecurityException when you add the trace listener to your configuration, then very probably the apppool identity does not have sufficient rights to create a file at the specified location (in the example: c:\). Try another location or give the apppool identity sufficient rights.

I've just been able to resolve this problem by downloading and using the latest build of log4net (revision 1072765) from SVN repository http://svn.apache.org/viewvc/logging/log4net/trunk/

Apparently this problem has been fixed long time ago but who knows when log4net 1.2.11 is going to be released.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!