Winston + Morgan Logging Production EC2

Below is my config Winston

we are using morgan

with it.

var winston = require('winston');
winston.emitErrs = true;

var logger = new winston.Logger({
    transports: [
        new winston.transports.File({
            level: 'info',
            filename: __dirname+'/log/all-logs.log',
            handleExceptions: true,
            json: true,
            maxsize: 5242880, //5MB
            maxFiles: 1500,
            colorize: false
        }),
        new winston.transports.Console({
            level: 'debug',
            handleExceptions: true,
            json: false,
            colorize: true,
            'timestamp' : true
        })
    ],
    exitOnError: false
});

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

      

This works, I had two main questions.

  • I wanted to understand in NODE.JS

    Production

    Environment on Server Amazon AWS EC2

    , is this ideal for files log

    to be generated in the same project folder or somewhere outside the project hierarchy?

  • When used morgan

    together with Winston

    , how can we use the code git

    to ignore files log

    ? They are restored even if they are deleted.

We start working at Winston and have no idea how to get around git

both log system

at the same time. Adding files log

to the file .gitignore

doesn't help either.

Also any general advice for Winston

logging into the platform EC2

?

+3


source to share





All Articles