title: deployed and running windows service does not log4net nor appears to pickup connection string to access database
body: <p>I have the typical &quot;it works on my machine&quot; debacle. I have code that works in visual studio and when published as executable like so:</p>
  <pre><code>dotnet publish C:\xyz\BlaSolutions\Project1\Project1.csproj -o C:\Project1Publication -r win-x64 -c Release /p:PublishSingleFile=true 
  </code></pre>
  <p>The code logs nicely using log4net and picks up db windows authentication using this connection string in a appsettings.json:</p>
  <p>&quot;Server=BestServerEver;Database=AllDataEva;Integrated Security=true;Connection Timeout=0&quot;</p>
  <p>I want to run this as windows service and uses these commands:</p>
  <pre><code>sc.exe create Project1 binPath= &quot;C:\Project1Publication\Project1.exe&quot; DisplayName= &quot;Amazing Windows Service&quot; type= own obj= &quot;xyz\un&quot; password= &quot;verysecret&quot;
  sc.exe start Project1
  </code></pre>
  <p>The windows service is deployed and started and does not appear to throw any events in the windows log. However no expected output is generated nor are any log4net outputs created (not even a log4net log file is generated as specified in the log4net.config. Presumably the appsettings.json + log4net.config should be consumed/picked up transparently by the windows service from C:\Project1Publication. I also specify the user name for the windows service to use, which would be used for the windows authentication to access the database given the above connection string.</p>
  <p>I know this is a bit of a long shot, but can someone see anything blatantly wrong with the above approach? Thanks.</p>
  <p>I have the sneaky suspicion that the account xyz\un requires more rights or something?</p>
  <p>PS:</p>
  <p>some log4net code - which appears to &quot;work on my machine&quot;</p>
  <pre><code>private readonly ILog _log4net;
  var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
  XmlConfigurator.Configure(logRepository, new FileInfo(&quot;log4net.config&quot;));
  _log4net = LogManager.GetLogger(typeof(Program));
  
  
  
  &lt;?xml version=&quot;1.0&quot;?&gt;
  
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name=&quot;log4net&quot; type=&quot;log4net.Config.Log4NetConfigurationSectionHandler, log4net&quot;/&gt;
    &lt;/configSections&gt;
  
    &lt;log4net&gt;
      &lt;appender name=&quot;RollingFileAppender&quot; type=&quot;log4net.Appender.RollingFileAppender&quot;&gt;
        &lt;file value=&quot;C:\Log\SehrInteresanteLogs.xml&quot; /&gt;
        &lt;appendToFile value=&quot;true&quot; /&gt;
        &lt;rollingStyle value=&quot;Size&quot; /&gt;
        &lt;maxSizeRollBackups value=&quot;1000&quot; /&gt;
        &lt;maximumFileSize value=&quot;10MB&quot; /&gt;
        &lt;staticLogFileName value=&quot;true&quot; /&gt;
        &lt;layout type=&quot;log4net.Layout.PatternLayout&quot;&gt;
          &lt;conversionPattern value=&quot;%date [%thread] %level %logger - %message%newline%exception&quot; /&gt;
        &lt;/layout&gt;
      &lt;/appender&gt;
      &lt;root&gt;
        &lt;level value=&quot;DEBUG&quot; /&gt;
        &lt;appender-ref ref=&quot;RollingFileAppender&quot; /&gt;
      &lt;/root&gt;
    &lt;/log4net&gt;
  
  &lt;/configuration&gt;
  </code></pre>