Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: winston.transports.Rotate is not a constructor #12

Open
nengine opened this issue Oct 9, 2017 · 4 comments
Open

TypeError: winston.transports.Rotate is not a constructor #12

nengine opened this issue Oct 9, 2017 · 4 comments

Comments

@nengine
Copy link

nengine commented Oct 9, 2017

Could you help me see what I might be doing wrong here? Thanks.

const winston = require('winston');
const { format } = require('logform');

require('dotenv').config();
require('winston-logrotate');

var rotateTransport = new winston.transports.Rotate({
        file: 'application.log',
        keep: 5,
        compress: true
});
TypeError: winston.transports.Rotate is not a constructor
    at Object.<anonymous> (C:\Users\nash\wsclient\app.js:25:23)
@ladariha
Copy link

Do you have winston version 3.0.0 ? It looks like this module is not compatible with it, only with winston 2.x

@lmacardoso
Copy link

lmacardoso commented Jan 10, 2018

Hi,

Check this example:

var winston = require('winston');
var Rotate = require('winston-logrotate').Rotate;

var rotateTransport = new Rotate({
        file: __dirname + '/log/debug.log', 
		colorize: false,
		timestamp: true,
		json: false,
		size: '10m',
		keep: 5,
		compress: true
});

var rotateTransportException = new Rotate({
        file: __dirname + '/log/exceptions.log', 
		colorize: false,
		timestamp: true,
		json: false,
		size: '10m',
		keep: 5,
		compress: true
});

var logger = new (winston.Logger)(
{
  transports: [
    new (winston.transports.Console)({ json: false, timestamp: true }),
    rotateTransport
  ],
  exceptionHandlers: [
    new (winston.transports.Console)({ json: false, timestamp: true }),
    rotateTransportException
  ],
  exitOnError: false
});


for (var i = 0 ; i < 10; i++)
{
	logger.info('Lapis Lapis Lapis Lapis Lapis Lapis Lapis Lapis Lapis Lapis Lapis Lapis Lapis ', i);
}

@demmer
Copy link
Contributor

demmer commented Jan 19, 2018

Note: This project needs a new maintainer as I am no longer actively developing or using this.

@shiwang987
Copy link

Same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants