Reputation: 93
I'm using nLog 4.0.1 in a Console Application in Visual Studio Express 2013.
Running the app in VS itself works; it works after compiling the .exe in a relative directory like bin\Debug
or bin\Release
, too.
However, it does not work if I compile it into another dir (\\192.168.3.55\vol3\programs\test
).
This is my app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- ... -->
</assemblyBinding>
</runtime>
<connectionStrings>
<!-- ... -->
</connectionStrings>
<appSettings>
<!-- ... -->
</appSettings>
<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">
<variable name="startDatetime" value="${date:format=yyMMdd}" />
<targets>
<target name="logfile" xsi:type="File" fileName="\\192.168.3.71\log\test_${startDatetime}.dbg" layout="[${date:format=yyyyMMddHHmmssfff}][${level}] ${message}" />layout="${date:format=yyyyMMddHHmmss} ${message}" />-->
<target xsi:type="ColoredConsole" name="console" encoding="utf-8" layout="${message}">
</target>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="logfile" />
<logger name="*" minlevel="Debug" writeTo="console" />
</rules>
</nlog>
</configuration>
This is the part of my code where exception occurs:
Imports NLog
Module Test
Public logger As Logger = LogManager.GetCurrentClassLogger()
'...
End Module
This is the part of my .vbproj:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace>
<Optimize>true</Optimize>
<OutputPath>\\192.168.3.55\vol3\programs\test\</OutputPath>
<DocumentationFile>test.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
This is the Stacktrace (sorry, it's in German):
Unbehandelte Ausnahme: System.TypeInitializationException: Der Typeninitialisierer für "test.Test" hat eine Ausnahme verursacht. ---> System.Configuration.ConfigurationErrorsException: Beim Erstellen des Konfigurationsabschnittshandlers für "nlog" ist ein Fehler aufgetreten.: Der Typeninitialisierer für "NLog.Config.Configuration
ItemFactory" hat eine Ausnahme verursacht. (\\192.168.3.55\vol3\programs\test\test.exe.Config line 36) ---> System.TypeInitializationException: Der Typeninitialisierer für "NLog.Config.ConfigurationItemFactory" hat eine Ausnahme verursacht. ---> System.IO.DirectoryNotFoundException: Ein Teil des Pfades "\\192.168.3.55\vol3\vol3\programs\test" konnte nicht gefunden werden.
bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
bei System.IO.FileSystemEnumerableIterator`1.CommonInit()
bei System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
bei System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption, Boolean checkHost)
bei System.IO.Directory.InternalGetFiles(String path, String searchPattern, SearchOption searchOption)
bei NLog.Config.ConfigurationItemFactory.BuildDefaultFactory()
bei NLog.Config.ConfigurationItemFactory..cctor()
--- Ende der internen Ausnahmestapelüberwachung ---
bei NLog.Config.ConfigurationItemFactory.get_Default()
bei NLog.Config.XmlLoggingConfiguration..ctor(XmlElement element, String fileName)
bei NLog.Config.ConfigSectionHandler.Create(XmlNode section, IAppDomain appDomain)
bei System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionImpl(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXml
Reader reader)
bei System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.CreateSectionWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object pa
rentConfig, ConfigXmlReader reader)
bei System.Configuration.RuntimeConfigurationRecord.CreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader)
bei System.Configuration.BaseConfigurationRecord.CallCreateSection(Boolean inputIsTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentConfig, ConfigXmlReader reader, String filename, Int32 line)
--- Ende der internen Ausnahmestapelüberwachung ---
bei System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTruste
d, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
bei System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionReco
rd, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
bei System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
bei System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
bei System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
bei System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
bei System.Configuration.ConfigurationManager.GetSection(String sectionName)
bei NLog.LogFactory.get_Configuration()
bei NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey)
bei NLog.LogManager.GetCurrentClassLogger()
Means, part of the path \\192.168.3.55\vol3\vol3\programs\test
could not be found, which really does not exist. But I don't know how it happened, that "vol3" is taken twice. I use \\192.168.3.55\vol3\programs\test\
in my settings, but, after releasing in exactly this directory, nLog turns the path into \\192.168.3.55\vol3\vol3\programs\test
and fails.
How can I tell nLog to use the correct path?
Upvotes: 2
Views: 707
Reputation: 36710
This is a confirmed bug in 4.0.1 (not 4.0.0). This will be solved in 4.1.0.
Upvotes: 1
Reputation: 3986
We ran into the same problem. Downgrading NLog from 4.0.1 to 3.2.1 did the trick.
Upvotes: 1