我正在提供一項服務,即現在爲空,且僅使用NLog,但是當我啓動該服務時,出現以下錯誤;啓動服務的NLog異常
---------------------------
Services
---------------------------
Windows could not start the JobService service on Local Computer.
Error 1053: The service did not respond to the start or control request in a timely fashion.
---------------------------
OK
---------------------------
這是在事件查看器堆棧跟蹤:
Application: service.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Configuration.ConfigurationErrorsException
Stack:
at System.Configuration.ClientConfigurationSystem.EnsureInit(System.String)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(System.String)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(System.String)
at System.Configuration.ConfigurationManager.GetSection(System.String)
at NLog.Config.XmlLoggingConfiguration.get_AppConfig()
at NLog.LogFactory.get_Configuration()
at NLog.LogFactory.GetLogger(LoggerCacheKey)
at NLog.LogFactory.GetLogger(System.String)
at NLog.LogManager.GetLogger(System.String)
at JobsService.Service1..ctor()
NLog.config:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log" >
<targets>
<target name="file" xsi:type="File" layout="${longdate} ${logger} ${message}" fileName="${basedir}/${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="file" />
</rules>
</nlog>
的App.config已在configSections以下行,但不要知道是否需要
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
任何想法我可能錯過或忘記了什麼配置?
如果你在一個單獨的文件中有你的nlog配置,那麼你不需要app.config中的configsentions。只要刪除這一行:'' – nemesv
@nemesv同樣的結果 – Kiwi