Brief Introduction:
Logging Configuration Nodejs-log4js Log output
Reference: HTTP://CNODEJS.ORG/TOPIC/521EE22ABEE8D3CB12FC1F02
Https://github.com/nomiddlename/log4js-node/wiki/Date%20rolling%20file%20appender
Steps:
1. Enter Express project root path, download Log4js library file
NPR Install LOG4JS
2. Configure LOG4JS Files
Logger.js
/**
* LOG4JS log Output configuration file
* @type {EXPORTS} * * *
var log4js = require (' Log4js ');
Logger Configure
Log4js.configure {
appenders: [
{type: ' console '}, {
type: ' Datefile ',
FileName: ' Logs/log ', pattern
: "_yyyy-mm-dd",
maxlogsize:1024,
alwaysincludepattern:false,
Backups:4,
Category: ' Logger '
}
],
replaceconsole:true
});
Module.exports = Log4js.getlogger (' logger ');
Modular declaration of the Logger
When the project is started, log files are immediately generated under the Logs folder.
At the beginning of the document, the Datefile file updates the file in the daily midnight, and the file of the previous day is automatically added to the end of the date format.
eg
Modify Windows Time
Before the midnight of the day
The logs folder is then generated