Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NLog.config is not read when application is stored in a drive's root folder #4314

Closed
wilhelmmedetz opened this issue Feb 24, 2021 · 5 comments
Labels
bug Bug report / Bug fix
Milestone

Comments

@wilhelmmedetz
Copy link

NLog version: 4.7.7
Platform: .Net 4.5

  • What is the current result?
    • NLog.config is not read
  • What is the expected result?
    • NLog.config should be read
  • Did you checked the [Internal log]
    • not applicable
  • Please post full exception details (message, stacktrace, inner exceptions)
    • none
  • Are there any workarounds? yes/no
    • applicationname.exe.nlog or NLog.dll.nlog works
  • Is there a version in which it did work?
    • NLog.4.2.3
  • Can you help us by writing an unit test?
    • no

When starting an application from a drive's root directory the NLog.config in the root directory is not read.

Steps to reproduce:

  • create a simple console application with a NLog.config
  • map the build directory with subst to some drive
    e.g. subst h: C:\...\ConsoleApp\bin\Debug\net452
  • start the console application on the mapped drive
  • NLog.config is not read
@snakefoot
Copy link
Contributor

I can confirm that it also fails on my machine:

2021-02-24 20:27:21.8316 Debug Loading config from D:NLog.config
2021-02-24 20:27:21.8316 Error Failed loading from config file location: D:NLog.config Exception: System.UriFormatException: Invalid URI: A Dos path must be rooted, for example, 'c:\'.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Xml.XmlResolver.ResolveUri(Uri baseUri, String relativeUri)
   at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
   at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
   at NLog.Internal.Fakeables.AppEnvironmentWrapper.LoadXmlFile(String path)
   at NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfigurationFile(LogFactory logFactory, String configFile)
   at NLog.Config.LoggingConfigurationFileLoader.TryLoadLoggingConfiguration(LogFactory logFactory, String configFile, LoggingConfiguration& config)
2021-02-24 20:27:21.8650 Debug Found assembly location directory: 'D:\' (ConsoleApp2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null)
2021-02-24 20:27:21.8650 Debug Targets not configured for logger: ConsoleApp2.Program

@snakefoot snakefoot added the bug Bug report / Bug fix label Feb 24, 2021
@snakefoot snakefoot added this to the 4.7.8 milestone Feb 24, 2021
@snakefoot
Copy link
Contributor

Think bug was introduced with #2846 in NLog 4.5.9

@snakefoot
Copy link
Contributor

@wilhelmmedetz Thank you for reporting this issue. Have created #4316 to fix the bug.

@snakefoot
Copy link
Contributor

Resolved by #4316

@snakefoot
Copy link
Contributor

NLog ver. 4.7.8 has been released: https://www.nuget.org/packages/NLog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report / Bug fix
Projects
None yet
Development

No branches or pull requests

2 participants