log4js 的安装设置和实例

发布时间 2023-06-09 11:34:23作者: 城南城南

1、 安装

yarn add log4js -D

 2、设置

const log4js = require('log4js')

 3、实例

var log = log4js.getLogger();
// logger
app.use(async (ctx, next) => {
  // const start = new Date()
  await next()
  // const ms = new Date() - start
  // console.log(`${ctx.method} ${ctx.url} - ${ms}ms`)
  log.level = "debug";
  log.debug("Some debug messages");
})