Log4Net 在开发机器上工作,部署到共享主机时失败(使用相同的 db/connstring) [英] Log4Net works on Dev machine, fails when deployed to shared host (using same db/connstring)

查看:15
本文介绍了Log4Net 在开发机器上工作,部署到共享主机时失败(使用相同的 db/connstring)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地机器上配置了 log4net 并且工作正常,但是当我部署到我的主机 (godaddy) 时,它无声无息地失败了.我在我的开发机器和主机上使用相同的数据库/配置文件.我的 log4net 引用设置为复制本地,并且 log4net.dll、.pdb 和 .xml 存在于主机上的 bin 中.这是一个 asp.net mvc 应用.

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.

不抛出异常,应用程序按预期运行(减去日志记录)

这是在 SQL Server 2005 上运行的虚拟主机是 IIS 7

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?

推荐答案

根据我的经验,log4net 通常会吞下任何内部错误,只会导致日志语句不产生任何结果.

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

您可能想尝试的是启用 log4net 的内部日志记录.您可以通过将以下内容添加到 appSettings 部分来实现:

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" />

这会设置属性 LogLog.InternalDebuggingtrue.log4net 现在将记录到标准输出和错误流以及配置的跟踪侦听器.

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>

log4net 内部记录的所有消息都将出现在 TextWriterOutput.log 中.如果在将跟踪侦听器添加到配置时收到 SecurityException,则很可能 apppool 身份没有足够的权限在指定位置创建文件(在示例中:c:).尝试其他位置或为应用程序池标识提供足够的权限.

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.

这篇关于Log4Net 在开发机器上工作,部署到共享主机时失败(使用相同的 db/connstring)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆