-
Notifications
You must be signed in to change notification settings - Fork 156
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
config: Flag to disable access logger #438
Conversation
I typically redirect the access log on stdout to /dev/null, and log stderr to file. For me the possibility to enable/disable access log from configuration file, could be useful if combined with support for reloading configuration file via SIGHUP, as discussed in #352 |
Thanks for the PR @LINKIWI. This is related to #408 (FYI @glukasiknuro). I like these changes, but I would like to take some time to think through the command line flag/config file setting before merging. In particular I wonder if it would be better to use a more flexible setting than a boolean? Let's discuss some options before implementing them. One possibility I have been thinking about recently: @ulrfa: I have been doing some experimental refactoring that would make #352 a little easier to achieve. But it's still early days. |
I also like the idea of a leveled access logger. Happy to send a patch to this PR if that's the preferred direction. In terms of implementation, there's a few ways I think is reasonable:
|
If we were to add Or we could use integers, but then we should define three levels now: I think I prefer the string values better (though we could store the value as an integer internally). What does everyone else think? |
I'm +1 to |
OK- let's go ahead with this. |
Changes:
I didn't create constants for Additional manual verification: $ bazelisk run //:bazel-remote -- --dir /tmp/bazel --max_size 1 --port 8080 --access_log_level invalid
...
2021/05/14 18:37:07 bazel-remote built with go1.16.2 from git commit ec16031f6133df98481eb48df8137d1204ba2b63.
'access_log_level' must be set to either "none" or "all"
... |
Thanks- squashed and added to the master branch. |
The access logger can be quite noisy when
bazel-remote
is serving thousands of HTTP requests. This PR proposes the addition of a configuration switch to disable the access logger.The changes:
*log.Logger
instances to theConfig
structconfig/logger.go
[+]disable_access_log
available both as a CLI flag and in the YAML configuration to disable the access logger[+] This approach, I think, makes it easier to make further customizations to the logging behavior in the future. For example, this PR doesn't touch the behavior of the error logger, but I suppose there could be a use case for suppressing those messages as well.
[+] This is also required because the current implementation (on master) creates the loggers before the config is read. This change proposes creating the loggers after the config is read because we need to have a parsed config to decide how to create the loggers.
Test:
Help text:
Default behavior (no change compared to current master):
Disabled access logger via CLI flag:
Disabled access logger via config file: