Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

494
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda