Error: ENOENT with Bunyan spin file registration (NodeJS)

I am using the Bunyan module for NodeJS logging. When I try to use a rotating file type, it crashes my application every time and outputs this error:

Error: ENOENT, rename 'logs / info.log.3'

However, this never happens at the same time, so I can’t find any logic ... Here is how I manage my registrar:

var log = Bunyan.createLogger(config.log.config);
log.info('App started, ' + process.env.NODE_ENV);

And here is my config.json:

  {
    "name"    : "app",
    "streams" : [
        {
            "type"  : "rotating-file",
            "period": "5000ms",        //Low period is for testing purposes
            "count" : 12,
            "level" : "info",
            "path"  : "logs/info.log"
        },
        {
            "type"  : "rotating-file",
            "period": "5000ms",
            "count" : 12,
            "level" : "error",
            "path"  : "logs/error.log"
        },
        {
            "type"  : "rotating-file",
            "period": "5000ms",
            "count" : 12,
            "level" : "trace",
            "path"  : "logs/trace.log"
        }
    ]
  }

Can anyone advise how to fix my problem? Thanks in advance.

+4
source share
5 answers

. , , . , , , . (, info.log.3).

, , , .

, . Bunyan, ( , common error.log), ( Node.js, ).

0

, ( ), + , Bunyan, , "" , WorkerStream. WorkerStream process.send, IPC . , . , . .

cluster.on('online', function (worker) {
  // New worker has come online.
  worker.on('message', function (msg) {
    /* Watch for log records from this worker and write them 
       to the real rotating log file.
    */
    if (msg.level) {
      log._emit(msg);
    }
  });
});
+1

@victorkohl, . , node.js.

Bunyan + node.js . .

0

, .

, logger - , .

, . , IPC, .

, , 2 . .

bunyan-rotating-file-stream

0

ln .

. ?

  • bunyan log4js . - . bunyan . .
  • log4js appender - . .
  • , fs.createWriteStream(name, {"flags": "a"}) fs.rename . , .
0
source

All Articles