ch-04-05 ๊ฐ์ winston log ์๋ฌ
winston์ด๋ winston-daily-rotate-file๋ชจ๋ ๋ฆฌ๋ด์ผ์ด ๋ง์ด ๋์ด์ ์ฌ์ฉ๋ฒ์ด ๋ฐ๋ ๊ฒ ๊ฐ์ต๋๋ค. ํด๋น ๊ฐ์๋ ์์ฑ๋์ง ๋ช๋
๋์๊ตฌ์. ๋ฐ๋ผ์ npm์ผ๋ก ์ฌ์ฉํ๋ ๋ช๋ช ๋ชจ๋์ ๊ฒฝ์ฐ, ์ ๋๋ก ๋์ํ์ง ์๋ ๊ฒฝ์ฐ, ํด๋น ๋ชจ๋์ ๊ตฌ๊ธ์ ๊ฒ์ํด์ ์ฌ์ฉ๋ฒ์ ๋ํด ์ฝ์ด๋ณด์๋ ํธ์ด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค. ํ์ฌ ๊ธฐ์ค์ผ๋ก๋ ์๋์ ๊ฐ์ด ์ฌ์ฉํ์๋ฉด ๋ ๊ฒ ๊ฐ์ต๋๋ค. let logger = winston.createLogger({ // level: 'info', // format: /* winston.format.json(), */ false, // defaultMeta: { service: 'user-service' }, transports: [ // log file์ ์ ์ฅํ deg message ์ค์ ์ธํ
new (winstonDaily)({ // file์ ๋ฟ๋ ค์ฃผ๋๊ฑฐ name: 'info-file', filename: './log/server_%DATE%.log', datePattern: 'yyyy-MM-DD', colorize: false, maxSize: 50000000, maxFiles: 1000, level: 'info', showLevel: true, json: false, timeStampFormat, timeStampFormat, }), // console์ฐฝ์ ๋ณด์ฌ์ค deg message ์ค์ ์ธํ
new (winston.transports.Console)({ //console์ ๋ฟ๋ ค์ฃผ๋๊ฑฐ name: 'debug-console', colorize: true, level: 'debug', showLevel: true, json: false, timeStampFormat: timeStampFormat }) ] });