【问题标题】:NServiceBus logging to custom logNServiceBus 记录到自定义日志
【发布时间】:2012-07-21 20:01:31
【问题描述】:

我注意到,当我在 NServiceBus.host.exe 上调用 /install 标志时,会在应用程序事件日志下创建一个事件日志源。问题是,我们已经将 NServiceBus L4N 配置为将事件写入同一源,但在自定义事件日志下。

这会导致问题,因为如果我们在自定义事件日志下创建源,安装将失败(NserviceBus 安装程序抛出 System.ArgumentException: Source blah already exists on the local computer)。

那么我们如何阻止 NServiceBus 安装程序尝试在应用程序事件日志下创建事件源?

我们正在使用 NServiceBus 3.0.1.0

谢谢

编辑 - 完整的堆栈跟踪

Creating EventLog source blah in log Application...

An exception occurred during the Install phase.
System.ArgumentException: Source blah already exists
on the local computer.

The Rollback phase of the installation is beginning.
Restoring event log to previous state for source blah
.
Service blah is being removed from the system...
Service blah was successfully removed from the system
.

The Rollback phase completed successfully.

Unhandled Exception: System.InvalidOperationException: The installation failed, and the rollback has been performed. ---> System.ArgumentException: Source blah already exists on the local computer.
   at System.Diagnostics.EventLog.CreateEventSource(EventSourceCreationData sourceData)
   at System.Diagnostics.EventLogInstaller.Install(IDictionary stateSaver)
   at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
   at System.ServiceProcess.ServiceInstaller.Install(IDictionary stateSaver)
   at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
   at Topshelf.Internal.Hosts.HostServiceInstaller.Install(IDictionary stateSaver) 
in d:\dev\open-source\topshelf\src\Topshelf\Internal\Hosts\HostServiceInstaller.cs:line 120
   at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
   at System.Configuration.Install.TransactedInstaller.Install(IDictionary savedState)
   --- End of inner exception stack trace ---
   at System.Configuration.Install.TransactedInstaller.Install(IDictionary savedState)
   at Topshelf.Internal.Hosts.HostServiceInstaller.Register() in d:\dev\open-source\topshelf\src\Topshelf\Internal\Hosts\HostServiceInstaller.cs:line 61
   at Topshelf.Internal.Actions.InstallServiceAction.Do(IRunConfiguration configuration) in d:\dev\open-source\topshelf\src\Topshelf\Internal\Actions\InstallServiceAction.cs:line 42
   at Topshelf.Runner.Host(IRunConfiguration configuration, String[] args) in d:\dev\open-source\topshelf\src\Topshelf\Runner.cs:line 70
   at NServiceBus.Hosting.Windows.Program.Main(String[] args) in d:\BuildAgent-03\work\nsb.masterbuild1\src\hosting\NServiceBus.Hosting.Windows\Program.cs:line 122

【问题讨论】:

  • NServiceBus 仅记录到控制台/文件,所以我很确定这与实际记录无关。我不是 100% 确定,但我认为在安装 Windows 服务时会创建事件源?
  • 可能是 topshelf 正在自动创建源。我需要更深入地挖掘
  • 我遇到了完全相同的问题。你有没有发现是什么原因造成的?
  • 您好 Nils,抱歉,我们通过以不同方式命名自定义事件日志源来解决此问题。在 yahoo 组 tech.dir.groups.yahoo.com/group/nservicebus记录这个问题你可能会得到更多快乐(没有双关语)

标签: nservicebus


【解决方案1】:

仅当我们将 Log4net 配置为与端点名称相同的事件源名称时才会出现此问题。

所以我们可以在我们的事件日志中使用不同的源名称(在我们的例子中,<endpoint-name>.l4n)。这将暂时解决这个问题。

【讨论】:

  • 我最终得到了相同的解决方法。我希望可以决定使用哪个事件源 NServiceBus(或 topshelf)。
【解决方案2】:

如果事情真的很糟糕,您可以在注册表中找到事件日志源

HKLM/SYSTEM/ControlSet001/services/eventlog/...

您可以从那里手动删除不再需要的事件日志源。

【讨论】:

  • Jarrett 这个问题不会通过手动操作来解决。我们所有的部署都是自动化的。
猜你喜欢
  • 2016-04-23
  • 1970-01-01
  • 1970-01-01
  • 2016-08-29
  • 2019-11-15
  • 2023-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多