2012-04-10 160 views
4

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

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

那么我们应该如何阻止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 
+0

NServiceBus只记录到控制台/文件,所以我非常确定这与实际的日志记录无关。我不是100%确定,但我认为安装Windows服务时会创建事件源? – 2012-04-10 13:28:14

+0

这可能是顶部自动创建源代码。我需要深入挖掘 – 2012-04-10 13:31:56

+0

我有完全相同的问题。你有没有发现是什么原因造成的? – 2012-12-18 11:52:24

回答

2

只有当我们log4net的配置使用相同的事件源名称为终点,会出现问题名称。

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

+0

我最终采用了相同的解决方法。我希望可以决定哪个事件源NServiceBus(或顶部)正在使用。 – 2012-12-18 14:20:48

2

如果事情真的梨形,你可以找到事件日志源在您的注册表

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

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

+0

Jarrett问题不会通过手动操作来解决。我们所有的部署都是自动化的。 – 2012-07-23 06:54:46