Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ def _start_async_llm_engine(
engine_client = AsyncLLM(
vllm_config=vllm_engine_config,
executor_class=executor_class,
log_requests=vllm_engine_args.enable_log_requests,
log_stats=not vllm_engine_args.disable_log_stats,
stat_loggers=custom_stat_loggers,
)
Expand Down
10 changes: 1 addition & 9 deletions python/ray/llm/_internal/serve/engines/vllm/vllm_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,7 @@ def get_initialization_kwargs(self) -> dict:
# For GPU mode, use "ray" backend (default)
engine_kwargs["distributed_executor_backend"] = "ray"

# TODO (Nikhil): Remove this once vLLM fully deprecates disable_log_requests.
if "disable_log_requests" in engine_kwargs:
logger.warning(
"disable_log_requests is set in engine_kwargs, but vLLM does not support it. Converting to enable_log_requests."
)
engine_kwargs["enable_log_requests"] = not engine_kwargs.pop(
"disable_log_requests"
)
elif "enable_log_requests" not in engine_kwargs:
if "enable_log_requests" not in engine_kwargs:
engine_kwargs["enable_log_requests"] = False

return engine_kwargs
Expand Down
2 changes: 2 additions & 0 deletions python/ray/serve/_private/logging_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ def configure_component_logger(
stream_handler.setFormatter(serve_formatter)
stream_handler.addFilter(log_to_stderr_filter)
stream_handler.addFilter(ServeContextFilter())
if logging_config.enable_access_log is False:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant for this PR?

stream_handler.addFilter(log_access_log_filter)
logger.addHandler(stream_handler)

# Skip setting up file handler and stdout/stderr redirect if `stream_handler_only`
Expand Down
39 changes: 39 additions & 0 deletions python/ray/serve/tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,45 @@ def __call__(self, req: starlette.requests.Request):
with pytest.raises(AssertionError):
check_log_file(resp["logs_path"], [".*model_not_show.*"])

def test_access_log_suppressed_in_stderr(self, serve_and_ray_shutdown):
"""Test that enable_access_log=False suppresses access logs in stderr.

Regression test: the log_access_log_filter was previously only applied
to the file handler (memory_handler), not the stream handler (stderr).
Since RAY_SERVE_LOG_TO_STDERR defaults to True, access logs appeared in
stderr even when enable_access_log=False.
"""
logger = logging.getLogger("ray.serve")

@serve.deployment(
logging_config={"enable_access_log": False},
)
class Model:
def __call__(self, req: starlette.requests.Request):
logger.info("user_log_should_appear")
return "ok"

serve.run(Model.bind())
url = get_application_url(use_localhost=True)

f = io.StringIO()
with redirect_stderr(f):
for _ in range(5):
resp = httpx.get(url)
assert resp.status_code == 200

# Give logs time to flush.
time.sleep(2)

stderr_output = f.getvalue()

# Normal user logs should still appear in stderr.
assert "user_log_should_appear" in stderr_output

# Access logs (replica-side "CALL" and proxy-side "GET /") should
# NOT appear in stderr when enable_access_log=False.
assert "CALL __call__ OK" not in stderr_output

@pytest.mark.parametrize("encoding_type", ["TEXT", "JSON"])
def test_additional_log_standard_attrs(self, serve_and_ray_shutdown, encoding_type):
"""Test additional log standard attrs"""
Expand Down