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?