Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

385
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda