forked from hangaoke1/blog-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logtest.js
41 lines (36 loc) · 1.1 KB
/
logtest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const log4js = require('log4js');
log4js.configure({
appenders: [
{
type: 'console',
category: "console"
}, //控制台输出
{
type: "dateFile",
// 绝对路径
filename: '/log/hangaoke',
pattern: "_yyyyMMdd.log",
absolute: true,
alwaysIncludePattern: true,
// maxLogSize: 20480,
// backups: 3,
category: 'logInfo'
}//日期文件格式
],
replaceConsole: true, //替换console.log
levels:{
logInfo: 'info', //info及以上级别输出到日志文件
console: 'debug' //debug及以上级别输出到控制台
}
});
const logger = log4js.getLogger('logInfo');
const logger2 = log4js.getLogger('console');
logger2.debug('hello 校的事发生');
logger2.info('hello 校的事发生');
console.log('hahaha');
logger.trace('Entering cheese testing');
logger.debug('Got cheese.');
logger.info('Cheese is Gouda.');
logger.warn('Cheese is quite smelly.');
logger.error('Cheese is too ripe!');
logger.fatal('盛大发售');