Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress unnecesssary internal info logs from clientconn.go #3918

Closed
ZhouyihaiDing opened this issue Oct 1, 2020 · 7 comments
Closed

Suppress unnecesssary internal info logs from clientconn.go #3918

ZhouyihaiDing opened this issue Oct 1, 2020 · 7 comments
Labels
Status: Duplicate Type: Feature New features or improvements in behavior

Comments

@ZhouyihaiDing
Copy link
Contributor

ZhouyihaiDing commented Oct 1, 2020

What did you do?

Run gRPC codelab.

What did you expect to see?

Clean log.

What did you see instead?

Unnecessary logs were dumped by default.

clientconn.go:162] [core]Channel Created
clientconn.go:249] [core]parsed scheme: ""
clientconn.go:255] [core]scheme "" not registered, fallback to default scheme
...
clientconn.go:681] [core]ClientConn switching balancer to "pick_first"
clientconn.go:696] [core]Channel switches to new LB policy "pick_first"
clientconn.go:737] [core]Subchannel Created
clientconn.go:737] [core]Subchannel(id:2) created
clientconn.go:1073] [core]Subchannel Connectivity change to CONNECTING
clientconn.go:1210] [core]Subchannel picks a new address "127.0.0.1:10000" to connect
clientconn.go:428] [core]Channel Connectivity change to CONNECTING
clientconn.go:1073] [core]Subchannel Connectivity change to READY
clientconn.go:428] [core]Channel Connectivity change to READY
...
clientconn.go:1437] [core]Subchannel Deleted
clientconn.go:1437] [core]Subchanel(id:2) deleted
clientconn.go:1029] [core]Channel Deleted
...

Note those logs weren't there by default before the import on 02/19.
Do we want to support verbosity level for internal logs or provide an easy way to disable those info logs?

@dfawley
Copy link
Member

dfawley commented Oct 1, 2020

These messages seem to meet the published standards for INFO log-level messages here:

https://github.com/grpc/grpc-go/blob/master/Documentation/log_levels.md#info

Perhaps you want to disable grpc info logs instead?

@dfawley dfawley added Status: Requires Reporter Clarification Type: Feature New features or improvements in behavior and removed Type: Bug labels Oct 1, 2020
@ZhouyihaiDing
Copy link
Contributor Author

There is no easy way to disable "info" logs for gRPC. The user needs to create a custom logger to discard those newly appeared logs. It would also be nice if we can provide an easy way to do so.

@dfawley
Copy link
Member

dfawley commented Oct 7, 2020

If you have an existing logger:

type MyInfoSinkLogger struct {
	grpclog.LoggerV2  // Embed the primary logger
}

func (MyInfoSinkLogger) Info(...) { }    // Override Info funcs
func (MyInfoSinkLogger) Infoln(...) { }  // to nops, so Info logs
func (MyInfoSinkLogger) Infof(...) { }   // are ignored.

If not, you can use https://godoc.org/google.golang.org/grpc/grpclog#NewLoggerV2:

	grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, <warning writer>, <error writer>)

@dfawley
Copy link
Member

dfawley commented Oct 7, 2020

The user needs to create a custom logger

I forgot to mention: info logs are off by default for the default logger, and are only enabled by setting the environment variable GRPC_GO_LOG_SEVERITY_LEVEL=info.

@ZhouyihaiDing
Copy link
Contributor Author

ZhouyihaiDing commented Oct 7, 2020

Currently these logs are enabled by default in glogger which doesn't check GRPC_GO_LOG_SEVERITY_LEVEL.
The internal user needs to replace the log by grpclog.SetLoggerV2 to disable these logs.
What do you think if we provide a similar switch like GRPC_GO_LOG_SEVERITY_LEVEL for glogger?

@dfawley
Copy link
Member

dfawley commented Oct 7, 2020

As part of the component logging #3617, we wanted to make this configurable per-module in addition to globally. This feature still needs to be designed, but we should do that instead of adding knobs to the glogger (which isn't really recommended for most users since it parses command-line flags).

@dfawley
Copy link
Member

dfawley commented Oct 7, 2020

Let's call this a dupe of the new issue I made to track the above, #3937.

@dfawley dfawley closed this as completed Oct 7, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Status: Duplicate Type: Feature New features or improvements in behavior
Projects
None yet
Development

No branches or pull requests

2 participants