grpc with Vertx Logs 需要解释
grpc with Vertx Logs Explanation Needed
我已经使用 Kotlin 实现了带有 Vertx 的 grpc API 并启用了 FINEST 日志级别以用于调试目的。在我的集成测试中,我尝试使用通道将 grpc 客户端连接到服务器。
客户端代码段:
val clientAsync1 = ctx.async()
val channel1 = VertxChannelBuilder
.forAddress(vertx, "localhost", 10000)
.usePlaintext(true)
.build()
val stub1 = ExampleGrpc.newVertxStub(channel1)
val request = builderUtil.buildRequest()
stub1.attemptFriendship(request) { stream ->
stream.handler { response ->
}
}
我在 grpc verticle 的日志中看到以下内容:
[main] 2018-05-24T12:42:27.69+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] Exiting idle mode
[grpc-default-executor-0] 2018-05-24T12:42:27.71+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] resolved address: {1}, config={2}
[main] 2018-05-24T12:42:27.713+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] {1} created for {2}
[main] 2018-05-24T12:42:27.759+09:00 FINE [io.grpc.internal.InternalSubchannel] [{0}] Created {1} for {2}
[vert.x-eventloop-thread-0] 2018-05-24T12:42:28.081+09:00 FINE [io.grpc.internal.InternalSubchannel] [{0}] {1} for {2} is ready
[vert.x-eventloop-thread-0] 2018-05-24T12:42:35.956+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] Created with target {1}
[vert.x-eventloop-thread-0] 2018-05-24T12:42:35.961+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] Exiting idle mode
[grpc-default-executor-0] 2018-05-24T12:42:35.962+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] resolved address: {1}, config={2}
[grpc-default-executor-0] 2018-05-24T12:42:35.962+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] {1} created for {2}
[grpc-default-executor-0] 2018-05-24T12:42:35.963+09:00 FINE [io.grpc.internal.InternalSubchannel] [{0}] Created {1} for {2}
[vert.x-eventloop-thread-0] 2018-05-24T12:42:35.974+09:00 FINE [io.grpc.internal.InternalSubchannel] [{0}] {1} for {2} is ready
[vert.x-eventloop-thread-0] 2018-05-24T12:42:46.808+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] shutdown() called
[vert.x-eventloop-thread-0] 2018-05-24T12:42:46.81+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] Shutting down
谁能解释一下 [{0}]{1}{2}
是什么意思?请注意,已创建多个通道来完成测试,并且响应是流。
{0}
格式是MessageFormat which is the default formatter used by java.util.logging
. When calling a method like log(Level level, String msg, Object[] params)
的格式,params
应该和msg
组合成日志字符串。这是有益的,因为如果不打印日志,则可以避免处理。
如 java.util.logging.Logger
文档中所示:
Typically, formatters use java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two parameters as strings.
虽然在您的环境中配置的 java.util.logging.Formatter
似乎没有这样做。
我已经使用 Kotlin 实现了带有 Vertx 的 grpc API 并启用了 FINEST 日志级别以用于调试目的。在我的集成测试中,我尝试使用通道将 grpc 客户端连接到服务器。
客户端代码段:
val clientAsync1 = ctx.async()
val channel1 = VertxChannelBuilder
.forAddress(vertx, "localhost", 10000)
.usePlaintext(true)
.build()
val stub1 = ExampleGrpc.newVertxStub(channel1)
val request = builderUtil.buildRequest()
stub1.attemptFriendship(request) { stream ->
stream.handler { response ->
}
}
我在 grpc verticle 的日志中看到以下内容:
[main] 2018-05-24T12:42:27.69+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] Exiting idle mode
[grpc-default-executor-0] 2018-05-24T12:42:27.71+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] resolved address: {1}, config={2}
[main] 2018-05-24T12:42:27.713+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] {1} created for {2}
[main] 2018-05-24T12:42:27.759+09:00 FINE [io.grpc.internal.InternalSubchannel] [{0}] Created {1} for {2}
[vert.x-eventloop-thread-0] 2018-05-24T12:42:28.081+09:00 FINE [io.grpc.internal.InternalSubchannel] [{0}] {1} for {2} is ready
[vert.x-eventloop-thread-0] 2018-05-24T12:42:35.956+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] Created with target {1}
[vert.x-eventloop-thread-0] 2018-05-24T12:42:35.961+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] Exiting idle mode
[grpc-default-executor-0] 2018-05-24T12:42:35.962+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] resolved address: {1}, config={2}
[grpc-default-executor-0] 2018-05-24T12:42:35.962+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] {1} created for {2}
[grpc-default-executor-0] 2018-05-24T12:42:35.963+09:00 FINE [io.grpc.internal.InternalSubchannel] [{0}] Created {1} for {2}
[vert.x-eventloop-thread-0] 2018-05-24T12:42:35.974+09:00 FINE [io.grpc.internal.InternalSubchannel] [{0}] {1} for {2} is ready
[vert.x-eventloop-thread-0] 2018-05-24T12:42:46.808+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] shutdown() called
[vert.x-eventloop-thread-0] 2018-05-24T12:42:46.81+09:00 FINE [io.grpc.internal.ManagedChannelImpl] [{0}] Shutting down
谁能解释一下 [{0}]{1}{2}
是什么意思?请注意,已创建多个通道来完成测试,并且响应是流。
{0}
格式是MessageFormat which is the default formatter used by java.util.logging
. When calling a method like log(Level level, String msg, Object[] params)
的格式,params
应该和msg
组合成日志字符串。这是有益的,因为如果不打印日志,则可以避免处理。
如 java.util.logging.Logger
文档中所示:
Typically, formatters use java.text.MessageFormat style formatting to format parameters, so for example a format string "{0} {1}" would format two parameters as strings.
虽然在您的环境中配置的 java.util.logging.Formatter
似乎没有这样做。