NServiceBus日志记录到自定义日志

NServiceBus日志记录到自定义日志,nservicebus,Nservicebus,我注意到,当我在NServiceBus.host.exe上调用/install标志时,会在应用程序事件日志下创建一个事件日志源。问题是,我们已将NServiceBus L4N配置为在自定义事件日志下将事件写入同一源 这会导致问题,因为如果我们在自定义事件日志下创建源,安装将失败(NserviceBus安装程序抛出System.ArgumentException:本地计算机上已经存在源blah) 那么,我们如何阻止NServiceBus安装程序尝试在应用程序事件日志下创建事件源呢 我们正在使用NS

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

这会导致问题,因为如果我们在自定义事件日志下创建源,安装将失败(NserviceBus安装程序抛出System.ArgumentException:本地计算机上已经存在源blah)

那么,我们如何阻止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

只有在使用与端点名称相同的事件源名称配置Log4net时,才会出现此问题


因此,我们可以在事件日志中使用不同的源名称(在本例中,
.l4n
)。这将暂时解决这个问题。

如果事情进展顺利,您可以在注册表中找到事件日志源

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

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

NServiceBus只记录到控制台/文件,因此我很确定这与实际记录无关。我不是100%确定,但我认为事件源是在安装windows服务时创建的?可能是topshelf正在自动创建源。我需要再深入一点我也有同样的问题。你有没有发现是什么原因造成的?嗨,尼尔斯,很抱歉,我们以不同的方式命名自定义事件日志源,从而解决了这个问题。在yahoo group(没有双关语)Jarrett上记录这个问题,你可能会得到更多的乐趣。这个问题不会通过手动操作来解决。我们所有的部署都是自动化的,我最后也做了同样的工作。我希望可以决定NServiceBus(或topshelf)正在使用哪个事件源。