优化Node下Log4js输出格式

修改前

.\node_modules\log4js\lib\layouts_new.js
1
2
3
4
5
6
7
8
9
10
11
function timestampLevelAndCategory(loggingEvent, colour, timezoneOffset) {
return colorize(
formatLogData(
'[%s] [%s] %s - '
, dateFormat.asString(loggingEvent.startTime, timezoneOffset)
, loggingEvent.level
, loggingEvent.categoryName
)
, colour
);
}

输出样式:

修改后

.\node_modules\log4js\lib\layouts_new.js
1
2
3
4
5
6
7
8
9
10
11
function timestampLevelAndCategory(loggingEvent, colour, timezoneOffset) {
return colorize(
formatLogData(
'[%s] [%s] %s | '
, dateFormat.asString(loggingEvent.startTime, timezoneOffset)
, (loggingEvent.level+' ').slice(0,5)
, loggingEvent.categoryName
)
, colour
);
}

输出样式:

如果觉得我的文章对您有用,请随意打赏。您的支持将是我继续创作的动力!