[Serve] Fix enable_access_log=False not suppressing access logs on stderr#60822
Open
kouroshHakha wants to merge 5 commits intoray-project:masterfrom
Open
[Serve] Fix enable_access_log=False not suppressing access logs on stderr#60822kouroshHakha wants to merge 5 commits intoray-project:masterfrom
kouroshHakha wants to merge 5 commits intoray-project:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request addresses a bug where access logs were not being suppressed on stderr when enable_access_log=False was specified in the logging configuration. The root cause was correctly identified as the log_access_log_filter not being applied to the stream_handler. The fix adds this filter to the stream_handler, which is consistent with the existing logic for the file-based memory_handler. The change is clear, targeted, and effectively resolves the issue. The accompanying explanation in the pull request description is excellent.
abrarsheikh
approved these changes
Feb 7, 2026
| logger = logging.getLogger("ray.serve") | ||
|
|
||
| @serve.deployment( | ||
| logging_config={"enable_access_log": False}, |
Contributor
There was a problem hiding this comment.
can we extend this test to test both behaviors, that access log should be and shouldn't be generated based on enable_access_log?
…ix-uvicorn-logs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LoggingConfig(enable_access_log=False)does not suppress access logs from stderr. Thelog_access_log_filteris only applied to the file handler (memory_handler), not thestream_handler. SinceRAY_SERVE_LOG_TO_STDERRdefaults toTrue, access logs bypass the filter entirely.Reproduction
Expected: No access log lines in stderr.
Actual:
These lines appear in stderr despite
enable_access_log=Falsebeing set at both deployment and global level.Root Cause
In
configure_component_logger()(ray/serve/_private/logging_utils.py), thelog_access_log_filteris added tomemory_handler(file handler) but never tostream_handler(stderr handler):Fix
Add the same
log_access_log_filterto thestream_handlerwhenenable_access_log is False:A regression test (
test_access_log_suppressed_in_stderr) is added to verify access logs are filtered from stderr while normal user logs still appear.