Log4Net 在开发机器上工作,部署到共享主机时失败(使用相同的 db/connstring)
我在本地计算机上配置了 log4net 并且工作正常,但是当我部署到我的主机(godaddy)时,它会默默地失败。我在我的开发机器和主机上使用相同的数据库/配置文件。我的 log4net 引用设置为复制本地,并且 log4net.dll、.pdb 和 .xml 存在于主机上的 bin 中。这是一个 ASP.NET MVC 应用程序。
编辑:不会引发异常,并且应用程序按预期运行(减去日志记录)
这是在 SQL Server 2005 上运行 网络主机是 IIS 7
我的配置的重要细节是:
<root>
<level value="DEBUG" />
<appender-ref ref="AdoNetAppender" />
</root>
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
有人对要检查的事情有什么想法吗?
I have log4net configured and working fine on my local machine, however when I deploy to my host (godaddy) it fails silently. I am using the same database/config file on my dev machine, and on the host. My log4net reference is set to copy local, and the log4net.dll, .pdb, and .xml exist in the bin on the host. This is an asp.net mvc app.
Edit: No exceptions are thrown, and the application runs as expected (minus the logging)
This is running on SQL Server 2005
The webhost is IIS 7
salient details of my config are:
<root>
<level value="DEBUG" />
<appender-ref ref="AdoNetAppender" />
</root>
<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
<bufferSize value="1" />
<connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Anybody have any ideas on things to check?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据我的经验,log4net 通常会吞掉任何内部错误,只会导致日志语句不产生任何结果。
您可能想要尝试的是启用 log4net 的内部日志记录。您可以通过将以下内容添加到
appSettings
部分来完成此操作:这将设置属性
LogLog.InternalDebugging
为true
。 log4net 现在将记录到标准输出和错误流以及配置的跟踪侦听器。您可以使用以下配置来捕获记录的任何消息跟踪:
log4net 内部记录的所有消息都将出现在
TextWriterOutput.log
中。如果在将跟踪侦听器添加到配置中时收到SecurityException
,则应用程序池身份很可能没有足够的权限在指定位置创建文件(在示例中:c :\)。尝试其他位置或为应用程序池身份提供足够的权限。
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:This sets the property
LogLog.InternalDebugging
totrue
. 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:
All messages logged by log4net internally will appear in
TextWriterOutput.log
. If you get aSecurityException
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.我刚刚通过从 SVN 存储库下载并使用最新版本的 log4net(修订版 1072765)来解决此问题 http://svn.apache.org/viewvc/logging/log4net/trunk/
显然这个问题早就被修复了,但谁知道log4net 1.2.11什么时候发布。
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.