NLog doesn't seem to be logged in with ClickOnce, but works in dev

I am registering in my application through NLog. I am trying to collect several logs to diagnose the odd problem that I have on only one machine. In my NLog.Config, I have the following configuration:

<?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">

  <targets>
    <target name="logfile" xsi:type="File" fileName="${specialfolder:dir=PollingLogs:file=log.txt:folder=MyDocuments}" />
  </targets>

  <rules>
    <logger name="*" minlevel="Debug" writeTo="logfile" />
  </rules>
</nlog>

When I run development on my machine, I get the file log.txtcreated in the folder of my documents, and all logging is correct. However, when you deploy the application using ClickOnce, the log.txt file is not created (I can find at least). No errors occur, and my application works as usual, but nothing happens.

I do not understand how to debug this problem. Can anyone understand what they can share to help me work NLog correctly in a clickonce environment?

NLog .

+5
4

, NLog.config , ClickOnce.

NLog.config Project Solution Explorer Properties :

:

:

ClickOnce !:)

+5

, , , : log4net NLog XML   .

, KallDrexx. NLog, ( ), NLogHelper, , :

    public static XmlLoggingConfiguration SetNlogConfiguration()
    {
        var sr = new StringReader(NlogXmlConfigString1());
        var xr = XmlReader.Create(sr);
        var config = new XmlLoggingConfiguration(xr, null);
        return config;
    }

xml, :

    private static string NlogXmlConfigString1()
    {
        return  @"<nlog xmlns='http://www.nlog-project.org/schemas/NLog.xsd\'
                       xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance\'>
                  <targets>
                       <target name='logfile' xsi:type='File' fileName='${specialfolder:file=My_Logger.txt:folder=Desktop}' />
                  </targets>

                  <rules>
                    <logger name='*' minlevel='Info' writeTo='logfile' />
                  </rules>
                 </nlog>";
    }

, :

    NLog.LogManager.Configuration = NlogHelper.Helper.SetNlogConfiguration();

, , , , , . xml . , , , .

, , NLog .

+4

Sysinternal ProcessMon (). , , , / ...

ApplicationData CommonApplicationData LocalApplicationData Environment.SpecialFolder, MyDocuments...

+2

, .

NLog.config , , , , ClickOnce NLog.config , .

, : .

, , app.config, exe.config ClickOnce - , NLog. config .

0

All Articles