Skip to content

Log rotation does not work #838

@u4aew

Description

@u4aew

log4js version: 4.0.2

Updated from version 3.0.6 to 4.0.2 log rotation stopped working

Expected behavior

log rotation works

Actual behavior

log rotation does not work

How to reproduce

https://github.com/log4js-node/log4js-node/blob/v3.0.6/test/tap/dateFileAppender-test.js

it is enough to replace in the test configure with dateFileAppender
pattern on '-yyyy-mm-dd-hh-mm' and remove file deletion at the end
on

batch.test('configure with dateFileAppender', (t) => {
    log4js.configure({
      appenders: {
        date: {
          type: 'dateFile',
          filename: 'test/tap/date-file-test.log',
          pattern: '-yyyy-MM-dd-hh-mm',
          layout: { type: 'messagePassThrough' }
        }
      },
      categories: { default: { appenders: ['date'], level: 'WARN' } }
    });
    const logger = log4js.getLogger('tests');
    logger.info('this should not be written to the file');
    logger.warn('this should be written to the file');

    log4js.shutdown(() => {
      fs.readFile(path.join(__dirname, 'date-file-test.log'), 'utf8', (err, contents) => {
        t.include(contents, `this should be written to the file${EOL}`);
        t.equal(contents.indexOf('this should not be written to the file'), -1);
        t.end();
      });
    });

    // t.teardown(() => { removeFile('date-file-test.log'); });
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions