[英]How can I log `DEBUG` in lambda via `process.stdout.write`?
When I am using console.log
in my nodejs lambda, the log raw data shown in cloudwatch has timestamp as prefix.当我在我的 nodejs lambda 中使用
console.log
时,cloudwatch 中显示的日志原始数据以时间戳为前缀。
For example, console.log({a:1, b:2}
, will log例如,
console.log({a:1, b:2}
, 将记录
2020-09-21T13:05:02.312Z\t332c382e-605f-453f-b767-604dd5f542ab\tINFO\t{ a: 1, b: 2 }\n
I know that people are talking about using process.stdout.write
but I don't know how to log DEBUG
level in the cloudwatch.我知道人们在谈论使用
process.stdout.write
但我不知道如何在 cloudwatch 中记录DEBUG
级别。 Everything stdout.write
will be shown as INFO
.所有
stdout.write
都将显示为INFO
。
If you follow this example https://docs.aws.amazon.com/lambda/latest/dg/nodejs-logging.html如果你按照这个例子https://docs.aws.amazon.com/lambda/latest/dg/nodejs-logging.html
console.log or console.info (INFO)
console.warn (WARN)
console.debug (DEBUG)
I would recommend to use logger libraries like pino
or winston
loggers where there is much more control over logging.我建议使用像
pino
或winston
这样的记录器库,它们可以更好地控制日志记录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.