| 1 |
# Troubleshooting gRPC |
| 2 |
|
| 3 |
This guide is for troubleshooting gRPC implementations based on C core library (sources for most of them are living in the `grpc/grpc` repository). |
| 4 |
|
| 5 |
## Enabling extra logging and tracing |
| 6 |
|
| 7 |
Extra logging can be very useful for diagnosing problems. All gRPC implementations based on C core library support |
| 8 |
the `GRPC_VERBOSITY` and `GRPC_TRACE` environment variables that can be used to increase the amount of information |
| 9 |
that gets printed to stderr. |
| 10 |
|
| 11 |
## GRPC_VERBOSITY |
| 12 |
|
| 13 |
`GRPC_VERBOSITY` is used to set the minimum level of log messages printed by gRPC (supported values are `DEBUG`, `INFO` and `ERROR`). If this environment variable is unset, only `ERROR` logs will be printed. |
| 14 |
|
| 15 |
## GRPC_TRACE |
| 16 |
|
| 17 |
`GRPC_TRACE` can be used to enable extra logging for some internal gRPC components. Enabling the right traces can be invaluable |
| 18 |
for diagnosing for what is going wrong when things aren't working as intended. Possible values for `GRPC_TRACE` are listed in [Environment Variables Overview](doc/environment_variables.md). |
| 19 |
Multiple traces can be enabled at once (use comma as separator). |
| 20 |
|
| 21 |
``` |
| 22 |
# Enable debug logs for an application |
| 23 |
GRPC_VERBOSITY=debug ./helloworld_application_using_grpc |
| 24 |
``` |
| 25 |
|
| 26 |
``` |
| 27 |
# Print information about invocations of low-level C core API. |
| 28 |
# Note that trace logs of log level DEBUG won't be displayed. |
| 29 |
# Also note that most tracers user log level INFO, so without setting |
| 30 |
# GPRC_VERBOSITY accordingly, no traces will be printed. |
| 31 |
GRPC_VERBOSITY=info GRPC_TRACE=api ./helloworld_application_using_grpc |
| 32 |
``` |
| 33 |
|
| 34 |
``` |
| 35 |
# Print info from 3 different tracers, including tracing logs with log level DEBUG |
| 36 |
GRPC_VERBOSITY=debug GRPC_TRACE=tcp,http,api ./helloworld_application_using_grpc |
| 37 |
``` |
| 38 |
|
| 39 |
Known limitations: `GPRC_TRACE=tcp` is currently not implemented for Windows (you won't see any tcp traces). |
| 40 |
|
| 41 |
Please note that the `GRPC_TRACE` environment variable has nothing to do with gRPC's "tracing" feature (= tracing RPCs in |
| 42 |
microservice environment to gain insight about how requests are processed by deployment), it is merely used to enable printing |
| 43 |
of extra logs. |