Log4js exits when multiple processes write to the same file

19 Views Asked by At

Context: I have multiple processes running in parallel using log4js to write to the same logfile. After some time the logfile meets the maximum size limit and moves to a backup file. Unfortunately, while one process is moving/renaming the log file and creating a new one, all other processes will exit with the following error:

[Error: EPERM: operation not permitted, lstat 'E:\scripting_logs\myScript.6.log'] {
  errno: -4048,
  code: 'EPERM',
  syscall: 'lstat',
  path: 'E:\\scripting_logs\\myScript.6.log'
}

So my question is; what would be the best architectural solution to solve this problem?

I have tried making each process log to their own file but, my disk only has 100gb limit and I imagine we would run into space issues in a matter of months.

It also makes it difficult to ascertain which log file to use should something go awry.

0

There are 0 best solutions below