Absent timestamps in front of each command in Logs window during ComfyUI run

Where are they? No times, no dates …

1 Like

I already add new variable in public and private spaces PYTHONUNBUFFERED=1
Does not work …

1 Like

seems maybe normal…?


They are not “missing.” Hugging Face Spaces usually does not add timestamps in the Logs UI. It mostly shows whatever your container writes to stdout/stderr, line by line. If your program prints no date/time, the Logs tab shows no date/time. A Spaces forum reply summarizes the model: “It will be displayed if you print it.” (Hugging Face Forums)

PYTHONUNBUFFERED=1 cannot help with timestamps. It only changes when output appears (buffering), not what the line contains. People recommend it because Python buffering interacts poorly with the Spaces logs viewer, sometimes hiding stdout. (Hugging Face)

So the practical fix is simple: make your process output timestamps.


Why your expectation is reasonable

Hugging Face has other products where the UI does support timestamps as a display feature. Example: Inference Endpoints “Runtime Logs” explicitly has a timestamp toggle and describes timestamps defaulting to UTC. (Hugging Face)

Spaces Logs is different. It is closer to “raw process output.”


What you should do (in order)

Step 1: Confirm you are using a Docker Space (ComfyUI Spaces usually are)

The official ComfyUI Space example is a Docker Space with a Dockerfile and a plain CMD ["python", "main.py", ...]. It also sets a timezone TZ=America/Los_Angeles. (Hugging Face)

If your Space looks like that, you can fix this entirely in the Dockerfile without touching ComfyUI code.


Option A (recommended): Prefix every log line in the container

This is the highest-leverage solution for your exact ask: “timestamps in front of each command in Logs window.”

Use ts from moreutils

ts is built for this: it “adds a timestamp to the beginning of each line of input” and lets you choose the format. (Debian Manpages)

What to change

  1. Install moreutils in the image.
  2. Run ComfyUI through a shell pipeline and send both stdout and stderr into ts.

Example pattern:

RUN apt-get update && apt-get install -y moreutils && rm -rf /var/lib/apt/lists/*

ENV PYTHONUNBUFFERED=1
ENV TZ=Asia/Tokyo

CMD ["bash","-lc","set -euo pipefail; python -u main.py --listen 0.0.0.0 --port 7860 2>&1 | ts '[%Y-%m-%d %H:%M:%S]'"]

Why each piece matters:

  • 2>&1 makes stderr also get timestamps.
  • python -u and/or PYTHONUNBUFFERED=1 makes lines appear promptly (still useful). (Hugging Face)
  • TZ=Asia/Tokyo makes timestamps match your local expectation. The official template sets a TZ already, so this is a normal pattern. (Hugging Face)

If you cannot install extra packages

Use awk to prefix timestamps per line. This works with standard tools and is a common recommendation. (Stack Overflow)

Conceptual example:

python -u main.py ... 2>&1 | awk '{ print strftime("[%Y-%m-%d %H:%M:%S]"), $0; fflush(); }'

Option B: Add timestamps in Python logging (best if you control the log calls)

If the lines you care about are produced by Python logging, configure the format to include %(asctime)s.

Python’s logging docs show format strings using %(asctime)s for timestamps. (Python documentation)

Basic idea:

import logging
logging.basicConfig(
    format="%(asctime)s %(levelname)s %(name)s: %(message)s",
    datefmt="%Y-%m-%d %H:%M:%S",
)

When this helps:

  • You own the code that emits logs (your wrapper, custom nodes, scripts).
  • You want structured logs (level, module name) rather than just a timestamp prefix.

When it will not fully solve your problem:

  • Some lines come from non-logging print() calls or from subprocesses. Those will not automatically get timestamps unless you wrap stdout (Option A).

Option C: Get timestamps from the backend logs stream (when the UI won’t show them)

Even if the Spaces UI doesn’t render timestamps, the backend log stream can include them.

A huggingface_hub issue includes a working snippet that:

  • fetches a Space JWT
  • streams https://api.hf.space/v1/{space_id}/logs/{level}
  • prints event["timestamp"] and event["data"] (GitHub)

If you want “real timestamps” without modifying the container output, this is the path.


The common pitfall in your exact setup

You changed Settings → Variables. That sets env vars at runtime (or build args depending on Docker variables type). It does not alter log formatting by itself. Docker Spaces docs confirm variables are injected into the container environment, but you still need your app to use them. (Hugging Face)

So the failure mode is expected:

  • PYTHONUNBUFFERED=1 worked only for buffering (maybe you did not notice a difference).
  • It could never add dates to lines.

What I would do for a ComfyUI Space, specifically

If you are based on the official ComfyUI Space Dockerfile, you already have:

  • a Dockerfile you can edit
  • a CMD ["python", "main.py", ...] launch line (Hugging Face)

So the cleanest move is:

  1. Add moreutils
  2. Pipe python -u main.py ... 2>&1 | ts '...'
  3. Set TZ=Asia/Tokyo if you want local timestamps

That gives you exactly what you asked for: timestamps in front of each line in the Logs tab.


High-signal references


Summary

  • Spaces Logs UI usually does not add timestamps. It shows what your process prints. (Hugging Face Forums)
  • PYTHONUNBUFFERED=1 affects buffering, not timestamp formatting. (Hugging Face)
  • Best fix: pipe ComfyUI output through ts (or awk) in the Dockerfile CMD. (Debian Manpages)
  • Set TZ=Asia/Tokyo if you want local time. (Hugging Face)
  • If you want backend timestamps without changing output, stream logs via the SSE API shown in huggingface_hub issue #2667. (GitHub)

Becuase i do not use docker, but ZeroGPU + Gradio, I use your Option B and placed it in /ComfyUI/main.py

Works perfect!

Thank you so much for your effor!!

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.