本人主要是写python的,公司突然需要我写node代码,现在发现一个排错问题,我同事之前用winston的时候,并没有打上时间戳,感觉调试起来比较麻烦,有什么方法可以在winston日志中添加时间戳吗?
前段时间刚用了winston,加上timestamp即可
timestamp
@imhered 有对应的教程链接吗?或者例子代码,因为看到一些方法还是挺复杂的,但是我只是为了方便调试才去做这个
@ray1888
transports: [ new (winston.transports.File)({ name: 'error', filename: '/logs/crash.log', level: 'error', handleExceptions: true, timestamp: () => moment().format('YYYY-MM-DD HH:mm:ss.SSS'), humanReadableUnhandledException: true, json: false, colorize: true }) ]
这里的 timestamp 就是在log加入时间
好的,谢谢
@imhered 请问下 可以按天分割日志嘛 winston
@datura-lj 可以的,自己写或者用第三方的库,第三方的话用winston-daily-rotate-file
@imhered 谢谢,这个在 PM 2 cluster 模式下 正常吗
@datura-lj 没在 PM 2 cluster 模式下使用过这个
@imhered 刚试了下,还是不输出日志文件
CNode 社区为国内最专业的 Node.js 开源技术社区,致力于 Node.js 的技术研究。
前段时间刚用了winston,加上
timestamp即可@imhered 有对应的教程链接吗?或者例子代码,因为看到一些方法还是挺复杂的,但是我只是为了方便调试才去做这个
@ray1888
好的,谢谢
@imhered 请问下 可以按天分割日志嘛 winston
@datura-lj 可以的,自己写或者用第三方的库,第三方的话用winston-daily-rotate-file
@imhered 谢谢,这个在 PM 2 cluster 模式下 正常吗
@datura-lj 没在 PM 2 cluster 模式下使用过这个
@imhered 刚试了下,还是不输出日志文件