NLog: Xamarin UWP doesn't create a logfile

Type (choose one):

  • Bug

NLog version: 4.5.0-rc07

Platform: .Net 4.7

Current NLog config

<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="Trace" internalLogFile="C:\Users\<Path>\nlog-internal.log">
    <targets>
        <target name="file" xsi:type="File"
                layout="${date} | ${level} | ${message}"             
                fileName="${specialfolder:folder=ApplicationData}/qkiss_app-${shortdate}.log"
                keepFileOpen="false"
                encoding="utf-8" />
    </targets>
    <rules>
        <logger name="*" minlevel="Info" writeTo="file" />
    </rules>
</nlog>

No log file gets created, even when I use the absolute path for my machine: C:/Users/<UserName>/AppData/Local/Packages/<PackageName>/LocalState/<filePrefix>-${shortdate}.log

What is the current result?

  • The logger works fine in debug mode (UWP App)
  • Log file won’t be created under ReleaseMode. -> .Net Native compilation is on and may couse some errors (Reflection etc.)
  • ${environment:USERPROFILE} won’t work either

What is the expected result?

  • Creating the log file under ReleaseMode like under DebugMode

Did you checked the Internal log?

  • It wasn’t created. I did set internalLogLevel=Trace and path for internalLogFile=“C:\Users.…\log.log”

Please post full exception details (message, stacktrace, inner exceptions)

  • I don’t get an exception. The log file never gets created

Are there any workarounds?

  • None that I know of

Is there a version in which it did work?

  • I don’t it had ever worked with UWP ReleaseMode

Environment:

  • Visual Studio 2017 Version 15.6.4
  • .Net Versione 4.7.0.2556
  • NetStandard 2.0.1
  • NLOG 4.5.0-rc07

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (11 by maintainers)

Most upvoted comments

I’ve tried https://ci.appveyor.com/project/nlog/nlog/build/4.5.0-beta7414/artifacts and it worked pretty well. Thank you very much 😃. Will it be included in the next nupkg?

@MaxFe Was able to get an UWP App running with NetStandard2.0. Discovered that callsite and GetCurrentClassLogger didn’t like the new optimized Net Native.

Have updated the PR with additional fixes. Please try this instead:

https://ci.appveyor.com/project/nlog/nlog/build/4.5.0-beta7414/artifacts