log4js 的安装设置和实例

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");
})

 

 

posted @ 2023-06-09 11:28  侬侬发  阅读(83)  评论(0编辑  收藏  举报