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

384
Visualizações
Where to save CLI application log file that will work cross-platform?

I have an application that saves error logs into the same directory where the script was run. This is bad because it creates error.log files in random places. So I want to save the file into /var/log on GNU/Linux and I would like to have the same for Windows and macOS (and probably any other OS where NodeJS runs).

Is there a cross-platform way to get a log directory? So I can write logs there? Also how to work with that directory if it's owned by root. Or is there a better place to save NodeJS application logs?

The only directory cross-platform NodeJS directory is /tmp using:

const log_filename = path.join(os.tmpdir(), 'lips.error.log');

What is the best place to save logs where users can look them up? Same directory and /tmp directory are not good options in my option. What are the other options to save logs files?

What is the usual place where log files should be saved cross-platform in any CLI application?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

That's part of the fun -- there is no single directory to store logs, so you'll need to handle each supported OS separately.

  • Linux has options, but it would be good to go for the XDG specification way, as it's a reasonable standard that won't fill up system logs, and it will make it simple to isolate the applications logs.

  • macOS can use the ~/Library/logs folder.

  • Windows can use the AppData folder, usually AppData/Local.

over 4 years ago · Santiago Trujillo Relatório
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