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

383
Views
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 answers
Answer question

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 Report
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!