【问题标题】:Having trouble with Logging Application Block (EntLib 5) on Windows Server 2003R2在 Windows Server 2003R2 上记录应用程序块 (EntLib 5) 时遇到问题
【发布时间】:2010-07-16 13:54:55
【问题描述】:

典型场景,我使用 EntLib 5.0-April 2010 在我的开发机器上登录,一切正常,当我尝试在我们的 Web 服务器上投入生产时,它不起作用。

开发机器是Windows 7,使用VS2008。 生产服务器是带有 Microsoft .NET Framework 3.5 和 Service Pack 1 的 Windows Server 2003 R2。

我将 LAB DLL 包含在项目中(Common、Logging、ServiceLocation),而不是 GAC。

有什么想法吗?

提前致谢

【问题讨论】:

  • 你在登录什么? (文件、事件日志等)
  • 对不起。忘了提到我正在记录到事件日志。

标签: enterprise-library enterprise-library-5


【解决方案1】:

事实证明,由于我以管理员身份从 VS 运行 Web 应用程序,因此为我创建了 LogSource。在生产中,应用程序以正常权限运行,并且需要由管理员创建 LogSource。查看以下内容:

http://entlib.codeplex.com/wikipage?title=Why%20are%20messages%20not%20logged?&referringTitle=EntLib%20FAQ

【讨论】:

  • 一个简单的替代方法是编写一个小应用程序并在执行以下操作的服务器上以管理员身份运行:EventLog.CreateEventSource("LogSource", "LogName");
【解决方案2】:

创建一个控制台应用程序并编写以下行:

 class Program
    {
        static void Main(string[] args)
        {
            System.Diagnostics.EventLog.CreateEventSource("Enterprise Library Logging", "Application");
            System.Diagnostics.EventLog.WriteEntry("Application", "Sample error", System.Diagnostics.EventLogEntryType.Error);
        }
    }

将exe文件复制到服务器,并以管理员身份运行。然后,在事件查看器中,您将看到消息“示例错误”以确保行已执行。

它会解决你的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-09
    • 1970-01-01
    • 2011-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多