nodejs开发中使用log4j

var log4js = require("log4js");
var fs = require('fs');
var logConfig = JSON.parse(fs.readFileSync("./log4js.json", "utf8"));
log4js.configure(logConfig);
var logFile = log4js.getLogger('log_info');
logFile.info("********log");
logFile.error("错误log");

 

设置日志级别:在log4js.json文件

"levels":
{
  "log_error":"ALL",
  "console":"ALL",
  "log_info":"INFO"
}

nodejs-log4j demo 下载地址:https://download.csdn.net/download/paj123456789/10568437

你可能感兴趣的:(nodejs)