Skip to content

Testing size-based rotation, doesn't seem to work as expected #911

@ErisDS

Description

@ErisDS

I'm still running tests on log4js assessing it's viability as a replacement for the no longer maintained bunyan.

I just did a very very basic test on size-based rotation, and I'm not seeing the behaviour I'd expect.

Here's my test code:

const log4js = require('log4js');
const config = {
    appenders: {
        access: {type: 'file', filename: 'logs/test.log', maxLogSize: 5000, backups: 4}
    },
    categories: {default: {appenders: ['access'], level: 'debug'}}
};

log4js.configure(config);

const logger = log4js.getLogger('default');

logger.info('hello world 1');
logger.error(new Error('bad thing 1'));
logger.info('hello world 2');
logger.error(new Error('bad thing 2'));

This file is saved as logging.js and I'm hammering node logging.js locally on my macbook pro. I'm expecting there to quickly be 10 files, but there are never more than 2.

If I duplicate my log lines at the bottom so much more log content is output, I can get 10 files to be created, but never from consistently hitting the script.

I thought it might be related to this bug, because outputting more content in one stream/session creates more files: log4js-node/streamroller#34 - but it seems to be entirely to do with the number of backup files created, not the size of the individual files.

I'm looking for file size based rotation, not date based rotation, due the sheer volume of log files I'm going to be using this with - rotating all the log files across 1000s of apps at midnight causes performance problems 😬

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