Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

493
Views
NLog unable to create log file on Linux server (ASP.NET Core application)

It is working fine on the local windows system. When I deploy it on a Linux server it is neither logging logs nor creating log files.

nlog.config

<?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"
          autoReload="true"
          throwConfigExceptions="true">    
      
      <!-- enable asp.net core layout renderers -->
      <extensions>
        <add assembly="NLog.Web.AspNetCore"/>
      </extensions>
    
      <!-- the targets to write to -->
      <targets>
        <target 
          name="errorLogFile"
          xsi:type="File" 
          fileName="${currentdir}/logs/error/${date:format=yyyyMMdd}.txt"
          layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${callsite}|${message} ${exception:format=tostring} ${newline} "
          />
        
        <target 
          name="infoLogFile"
          xsi:type="File"
          fileName="${currentdir}/logs/info/${date:format=yyyyMMdd}.txt"
          layout="${longdate}|${event-properties:item=EventId_Id}|${uppercase:${level}}|${callsite}|${message} ${exception:format=tostring} ${newline} " 
          />    
      </targets>
      <rules>
        <logger name="Microsoft.*" minlevel="Info" maxlevel="Warn" writeTo="" final="true" />
        <logger name="*" minlevel="ERROR" writeTo="errorLogFile" />
        <logger name="*" minlevel="Info" maxlevel="Warn"  writeTo="infoLogFile" />
      </rules>
    </nlog>

Program.cs > CreateHostBuilder

            .ConfigureLogging((hostingContext, logging) =>
            {
                logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
                logging.AddConsole();
                logging.AddDebug();
                logging.AddEventSourceLogger();
                // Enable NLog as one of the Logging Provider
                logging.AddNLog();
            })
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!