diff --git a/python/ray/_private/worker.py b/python/ray/_private/worker.py index e00cd9311..84db983d9 100644 --- a/python/ray/_private/worker.py +++ b/python/ray/_private/worker.py @@ -1165,7 +1165,7 @@ def init( arguments is passed in. """ if configure_logging: - setup_logger(logging_level, logging_format) + setup_logger(logging_level, logging_format or ray_constants.LOGGER_FORMAT) # Parse the hidden options: _enable_object_reconstruction: bool = kwargs.pop( @@ -1192,8 +1192,6 @@ def init( _node_name: str = kwargs.pop("_node_name", None) # Fix for https://github.com/ray-project/ray/issues/26729 _skip_env_hook: bool = kwargs.pop("_skip_env_hook", False) - if not logging_format: - logging_format = ray_constants.LOGGER_FORMAT # If available, use RAY_ADDRESS to override if the address was left # unspecified, or set to "auto" in the call to init diff --git a/python/ray/tests/test_output.py b/python/ray/tests/test_output.py index 3b1f3d916..d827bbbe7 100644 --- a/python/ray/tests/test_output.py +++ b/python/ray/tests/test_output.py @@ -14,6 +14,21 @@ from ray._private.test_utils import ( ) +def test_logger_config(): + script = """ +import ray + +ray.init(num_cpus=1) + """ + + proc = run_string_as_driver_nonblocking(script) + out_str = proc.stdout.read().decode("ascii") + err_str = proc.stderr.read().decode("ascii") + + print(out_str, err_str) + assert "INFO worker.py:" in err_str, err_str + + @pytest.mark.skipif(sys.platform == "win32", reason="Failing on Windows.") def test_spill_logs(): script = """