Where are they? No times, no dates …
I already add new variable in public and private spaces PYTHONUNBUFFERED=1
Does not work …
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
- Install
moreutilsin the image. - 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>&1makes stderr also get timestamps.python -uand/orPYTHONUNBUFFERED=1makes lines appear promptly (still useful). (Hugging Face)TZ=Asia/Tokyomakes 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"]andevent["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=1worked 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:
- Add
moreutils - Pipe
python -u main.py ... 2>&1 | ts '...' - Set
TZ=Asia/Tokyoif 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
- Spaces logging behavior and unbuffered stdout discussion: https://huggingface.co/static-proxy/discuss.huggingface.co/t/spaces-runtime-logging/139383 (Hugging Face Forums)
- Why
PYTHONUNBUFFERED=1helps logs visibility (but not timestamps): https://huggingface.co/spaces/sayakpaul/demo-docker-gradio/discussions/3 (Hugging Face) - Official ComfyUI Space Dockerfile (shows
TZand plainCMD python main.py): https://huggingface.co/spaces/SpacesExamples/ComfyUI/blob/main/Dockerfile (Hugging Face) tsmanpage: what it does and format control: https://manpages.debian.org/testing/moreutils/ts.1.en.html (Debian Manpages)- Backend log streaming with timestamps (JWT + SSE): https://github.com/huggingface/huggingface_hub/issues/2667 (GitHub)
- Python logging reference (for
%(asctime)sformatting): https://docs.python.org/3/library/logging.html (Python documentation) - Contrast: HF product UI that does have timestamp toggle (Inference Endpoints logs): https://huggingface.co/docs/inference-endpoints/en/guides/logs (Hugging Face)
Summary
- Spaces Logs UI usually does not add timestamps. It shows what your process prints. (Hugging Face Forums)
PYTHONUNBUFFERED=1affects buffering, not timestamp formatting. (Hugging Face)- Best fix: pipe ComfyUI output through
ts(orawk) in the DockerfileCMD. (Debian Manpages) - Set
TZ=Asia/Tokyoif you want local time. (Hugging Face) - If you want backend timestamps without changing output, stream logs via the SSE API shown in
huggingface_hubissue #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!!
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.