Winston의 Log Format을 Customizing 하는 방법에 대해 알아본다.
Winston Log Format을 수정하기 위해서는 Winston Transport의 formatter 설정을 구현해야 한다.
- timestamp 및 output format 함수를 재구현
function _timestamp() {
return moment().format("YYYY-MM-DD HH:mm:ss.SSS");
}
function _customFormatter(options) {
return options.timestamp() +
' ['+ options.level.toUpperCase() + ']' +
'['+ options.meta.loggerName + '] ' +
(!options.meta.clientMessage ? options.message : options.meta.clientMessage);
}
var consoleAppender = new winston.transports.Console({
timestamp: _timestamp,
formatter: _customFormatter
});
var fileAppender = new winston.transports.File({
timestamp: _timestamp,
formatter: _customFormatter,
json: false,
filename: 'filelog.log'
});
'Node.js' 카테고리의 다른 글
| [NPM] 특정 버전 npm 설치 (0) | 2019.01.04 |
|---|---|
| [Node.js][Winston] Log File Managment (0) | 2017.02.03 |
| [Node.js] node 실행시 "/usr/bin/env: node: No such file or directory" 에러가 발생하는 경우 (0) | 2016.12.25 |
| [Node.js] NVM을 통한 nodejs 설치 (0) | 2016.12.21 |
| [BOWER] Proxy 설정 (0) | 2016.12.16 |

