How to write eventLog with Anoelog the DLLs are dynamically loaded into a window service.
Using NLog to 2.0.1 that I have to load a DLL as a Windows service that is dynamic, from within the Dell I log EventLog'm trying () NLog EventLog is custom and is designed by service installer.
Error:
The service can not be started. system. reflection. Targeted Inclusion Exception: An exception has been thrown to the goal of an invitation. --- & gt; System.TypeInitializationException: The type initializer for 'MyService.Worker' threw an exception. --- & gt; NLog.NLogConfigurationException: EventLog Error During Startup [eventLog_wrapped] --- & gt; System.IO.IOException: The network path was not found. Microsoft.Win32.RegistryKey.Win32ErrorStatic on Microsoft.Win32.RegistryKey.OpenRemoteBaseKey on System.Diagnostics.EventLog.GetEventLogRegKey system (Int32 errorCode, String str) (RegistryHive HKEY, string machineName, RegistryView footage) (string machine, qualified Boolean type) On System.Digagnostics.EventLog.FindSourceRegistration (String source, String machine name, Boolean read only, Boolean wantToCreate) on System.Digagnostics.EventLog._InternalLogNameFromSourceName (string source, string machine name) on System.Digagnostics.EventLog.LogNameFromSourceName (string source , String machinename) on NLog.Targets.EventLogTarg ... I Has built winForm app to test logging and required as logging work, but when I try to do my service is not
I "Local System" and " Network service ", I get a single error. No network path is accessed for "network path ...." so I'm not sure that it is trying to tell me.
My NLog is config / target:
& Lt; Variable name = "source" value = "MySource" /> & Lt; Target xsi: type = "EventLog" name = "log" log = "my service" source = "$ {source}" machineName = "." Layout = "$ {call}} $ {newline} $ {message} $ {newline} $ {exception: format = toastring}" /> Any feedback about how to get this work done will be appreciated.
well, embarrassing, but maybe someone will save some time.
A short answer, the nlog.config file is in the wrong directory.
There are two projects in the solution, service host / installer project and a project where the argument / work is done. The service is installed from the debug folder for the service host / installer (yet in the initial test). Logic DLL has been loaded by service HSOT from the Logic Project debug folder. The logic folder contains nlog.config so when the service starts the nlog.config file can not be found, where the service host is running.
The service has no reference to the host service.dll, there is no problem because the runtime loads the dll, but nlog.config file was a problem.
The simplest solution to create the service is to change the logic / task project output to be similar to the service host output directory.
No comments:
Post a Comment