# How to alter the logger format?

**URL:** <https://discuss.ray.io/t/how-to-alter-the-logger-format/23630>\
**Category:** Ray Core\
**Created:** [September 25, 2026, 2:06am UTC](https://discuss.ray.io/t/how-to-alter-the-logger-format/23630 "2026-09-25T02:06:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fosskers](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/fosskers/32/8576_2.png) [@fosskers](https://discuss.ray.io/u/fosskers)\
**Post date:** [September 25, 2026, 2:06am UTC](https://discuss.ray.io/t/how-to-alter-the-logger-format/23630/1 "2026-09-25T02:06:42Z")

</div>

**1. Severity of the issue: (select one)**  
 Medium: Significantly affects my productivity but can find a workaround.

**2. Environment:**

- Ray version: 2.58.0
- Python version: 3.13.15
- OS: Arch Linux

**3. What happened vs. what you expected:**

- Expected: To be able to disable the `(foo pid=123)`-style prefixing to log messages.
- Actual: I can’t seem to achieve this despite following Ray’s docs and Python’s `logging` module

Hi there, we have a fairly customized logging environment in our app, into which we are trying to integrate Ray. We format all of our messages as [logfmt](https://www.brandur.org/logfmt) , but Ray insists on prepending every log message with process information like `(foo pid=81717)`. I’d like to disable this completely. However, all my experiments have failed so far. I’m attempting things like this:

```auto
def configure_ray_logging() -> None:
    ray_logger = logging.getLogger("ray")
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    formatter = logging.Formatter("%(message)s")
    ch.setFormatter(formatter)
    ray_logger.addHandler(ch)

if __name__ == " __main__":
    ray.init(runtime_env={"worker_process_setup_hook": configure_ray_logging})
    # etc.

```

But this has no effect. The Ray workers still prepend the process info, which conflicts with logfmt. It prints a message like this:

```auto
(foo pid=81717) ts=2026-09-25T10:52:47.003 level=INFO msg=\"Got: 0\" run_id=TDIO9HpDwzAaBULy-FAYi exec_name=default_worker parent_run_id=6o1AtAS3jur-qnmC3di9z

```

How can I fix this? Thank you.

---

<div class="post-metadata">

**Author:** ![RunLLM](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/runllm/32/8249_2.png) [@RunLLM](https://discuss.ray.io/u/RunLLM)\
**Post date:** [September 25, 2026, 2:06am UTC](https://discuss.ray.io/t/how-to-alter-the-logger-format/23630/2 "2026-09-25T02:06:55Z")

</div>

Set the environment variable RAY\_DISABLE\_WORKER\_LOG\_PREFIX=1 before starting your Ray application to disable the (foo pid=123)-style prefix on worker logs. This will keep your log lines in logfmt or JSON format without Ray prepending process info, as confirmed in the official documentation and tests. Example:

```python
import os
os.environ["RAY_DISABLE_WORKER_LOG_PREFIX"] = "1"
import ray
ray.init()

```

Note: This must be set before importing ray. If you also want to avoid log deduplication suffixes, set RAY\_DEDUP\_LOGS=0 as well. Your custom logging setup via worker\_process\_setup\_hook does not affect the prefix; only the environment variable disables it.  
Sources:

- [Ray logging user guide](https://github.com/ray-project/ray/blob/master/doc/source/ray-observability/user-guides/configure-logging.md)
- [Ray logging test code](https://github.com/ray-project/ray/blob/master/python/ray/tests/test_logging_2.py)

Hint: Mention @Herald in the post for followups.

---

<div class="post-metadata">

**Author:** ![fosskers](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/fosskers/32/8576_2.png) [@fosskers](https://discuss.ray.io/u/fosskers)\
**Post date:** [September 25, 2026, 2:10am UTC](https://discuss.ray.io/t/how-to-alter-the-logger-format/23630/3 "2026-09-25T02:10:03Z")

</div>

@Herald This is frustrating because this isn’t mentioned in the official published documentation. It also doesn’t work for the currently published version of Ray.

EDIT: Hah, the feature was added two days after the current release was made.

---

<div class="post-metadata">

**Author:** ![fosskers](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/fosskers/32/8576_2.png) [@fosskers](https://discuss.ray.io/u/fosskers)\
**Post date:** [September 25, 2026, 2:18am UTC](https://discuss.ray.io/t/how-to-alter-the-logger-format/23630/4 "2026-09-25T02:18:13Z")

</div>

See also a related issue on GH: [[Core] Provide a way to disable the worker-log `(pid=…)` prefix without disabling driver forwarding or overriding the root logger · Issue #64992 · ray-project/ray · GitHub](https://github.com/ray-project/ray/issues/64992)
