Skip to content

Latest commit

 

History

History
 
 

10、express日志打印

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

express 日志

主要是用 express-winston 模块实现的

    const expressWinstom=require('express-winston');

    //正常请求日志
    app.use(expressWinstom.logger({
        transports:[
            new (winston.transports.Console)({
                json:true,
                colorize:true
            }),
            new winston.transports.File({
                filename:'logs/success.log'
            })
        ]
    }));
    //调用路由
    routes(app);
    //错误请求日志
    app.use(expressWinstom.errorLogger({
        transports:[
            new winston.transports.Console({
                json:true,
                colorize:true
            }),
            new winston.transports.File({
                filename:'logs/error.log'
            })
        ]
    }));