Wednesday 31 May 2017

Winston JS, format daily rotate filename

I'm trying to use Winston JS to log in console and in different files. At the moment the console log works fine but can't give to the file the name that I want: 2017-05-31_Node.log, what I get is 2017-05-31_Node.log2017-05-31.

Here is my transport code:

    import { DailyRotateFileTransportInstance, transports } from 'winston';
    import * as dailyRotateFile from 'winston-daily-rotate-file';
    import * as path from 'path';
    import * as moment from 'moment';

    import { LogConstants } from '../../constants';

    transports.DailyRotateFile = dailyRotateFile;

    export let DailyRotateFileTransport = new transports.DailyRotateFile({
        level: 'Error',
        filename: path.join(LogConstants.LogsDirectory, `${ moment().format('YYYY-MM-DD') }_Node.log`),
        datePattern: ''
    });

How can I have a file without the date at the end?



via Yiyi Chen

No comments:

Post a Comment