[英]NodeJS: How Is Logging Enabled for the @grpc/grpc.js Package
When creating a GRPC client in NodeJS, if I'm using the grpc
package , I can start my program with the GRPC_VERBOSITY
set to debug
environmental variable.在
grpc
创建 GRPC 客户端时,如果我使用的是grpc
包,我可以将GRPC_VERBOSITY
设置为debug
环境变量来启动我的程序。
$ GRPC_VERBOSITY=debug node index.js
and I'll get a ton of information about the network communication that's happening.我将获得大量有关正在发生的网络通信的信息。
However, if I switch out implementations and use the @grpc/grpc-js
package, GRPC_VERBOSITY=debug
has no effect.但是,如果我切换实现并使用
@grpc/grpc-js
包,则GRPC_VERBOSITY=debug
无效。
I've poked at the underlying typescript that implements @grpc/grpc-js
, and I see what look like logging calls .我已经研究了实现
@grpc/grpc-js
的底层打字稿,我看到了日志调用的样子。
So my question: How can I enable logging when using the @grpc/grpc-js
NPM package with NodeJS所以我的问题:如何在
@grpc/grpc-js
使用@grpc/grpc-js
NPM 包时启用日志记录
if (process.env.GRPC_VERBOSITY) {
switch (process.env.GRPC_VERBOSITY) {
case 'DEBUG':
_logVerbosity = LogVerbosity.DEBUG;
break;
case 'INFO':
_logVerbosity = LogVerbosity.INFO;
break;
case 'ERROR':
_logVerbosity = LogVerbosity.ERROR;
break;
default:
// Ignore any other values
}
}
Set GRPC_VERBOSITY=DEBUG
in uppercase将
GRPC_VERBOSITY=DEBUG
设置为大写
Also, according to this , you have to set GRPC_TRACE
to specify what kind of logs you want to see.另外,根据this ,您必须设置
GRPC_TRACE
以指定要查看的日志类型。 To see all logs, you can set it to all
.要查看所有日志,您可以将其设置为
all
。
So, In your case, the command becomes所以,在你的情况下,命令变成
GRPC_VERBOSITY=DEBUG GRPC_TRACE=all node index.js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.