Skip to content

Rolling Log Files are not Respected Between runs #842

@lucasvwamp

Description

@lucasvwamp

From the Discussion on Slack:
The rolling file appender doesn't appear to respect files between runs. If a run generates log.txt and log.1.txt.gz before terminating, the next run will start appending to log.txt, but when the file size is hit, log.1.txt.gz is appended to instead of being moved to log.2.txt.gz and a new log.1.txt.gz being created.

This can be seen by running the following file until a gz is created, stopping execution, and then starting again. Eventually, the first gz file will be appended to instead of moved. There is no difference when not using compression.

/* jshint esversion: 6 */
const log4js = require('log4js');
log4js.configure({
  "appenders": {
    "handler": {
      "type": "file",
      "filename": "logs/handler.log",
      "maxLogSize": 100000,
      "backups": 5,
      "keepFileExt": true,
      "compress": true
    }
  },
  "categories": {
    "default": { "appenders": ["handler"], "level": "debug" },
    "handler": { "appenders": ["handler"], "level": "debug" },
  }
});

var logsToTest = [
  "handler"
];

var logStartDate = new Date();

var loggers = logsToTest.map(log => log4js.getLogger(log));

// write out a lot
setInterval(function() {
  loggers.forEach(logger => logger.info("TESTING LOGGER!!!!!!" + logStartDate));
}, 10);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions