Winston: maxSize of file transport isn't working.

Created on 5 Apr 2018  路  5Comments  路  Source: winstonjs/winston

const options = {
    level: 'info',
    filename: path.join('gis-service.log'),
    maxSize: 500,
    // maxFiles: 5,
    logstash: true,
    tailable: true,
    // zippedArchive: true,
    handleExceptions: true
};
const consoleOptions = {
    level: 'info',
    colorize: true,
    timestamp: true
};

const logger = winston.createLogger({
    level: 'info',
    format: winston.format.combine(
        winston.format.timestamp(),
        winston.format(function dynamicContent(info, opts) {
            info.message = info.message;
            return info;
        })(),
        winston.format.simple()
    ),
    transports: [
        new winston.transports.File(options),
        new winston.transports.Console(consoleOptions)
    ],
    exitOnError: false
});

logger.stream = {
    write: function(message, encoding){
        logger.info(message);
    }
};

This is my config, but file already is 12 KB and new file hasn't created.
Help me, please :).

duplicate

Most helpful comment

Isn't it maxsize?

All 5 comments

Any Solution for this??

Isn't it maxsize?

Sorry :)

const options = {
level: 'info',
filename: 'luluuuuuuuuuuuuuuuuu.log',
maxsize: 2000,
maxFiles: 5,
tailable: true,
zippedArchive: true,
handleExceptions: true
};

now it's working but when I write in file without breaks, it's size grows to 5 KB but maxsize is 2000 bytes. After restarting my service it finally creates new file and archived old file.

capture

This is a duplicate of #1174 鈥撀爌lease see the discussion around the approach https://github.com/winstonjs/winston/issues/1174#issuecomment-384512885

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mohanen picture mohanen  路  4Comments

Tonacatecuhtli picture Tonacatecuhtli  路  4Comments

sinai-doron picture sinai-doron  路  3Comments

Infinitay picture Infinitay  路  3Comments

pocesar picture pocesar  路  3Comments