nvflare.app_common.logging.job_log_receiver module

class JobLogReceiver(dest_dir: str | None = None, idle_timeout: float = 30.0)[source]

Bases: Widget

Receives live log data streamed by JobLogStreamer.

JobLogReceiver accepts a live stream: each chunk is written directly to its final file as it arrives so that the log can be followed with tail -f on the server while the job runs. When the stream closes (normal EOF, job abort, or idle timeout) the file is handed to the job manager for storage.

The destination file is written to {dest_dir}/{job_id}/{client_name}/{log_file_name}, making it easy to locate and tail during a run.

This widget can be placed in either of two locations:

Job-level configuration (config_fed_server.json)

Add it via job.to_server(JobLogReceiver()) in the Job API, or declare it in the job’s server config. In this mode the handler is registered on START_RUN (and on ABOUT_TO_START_RUN where available) so that the stream handler is wired up before any client chunk can arrive. The widget is only active for that specific job.

System-level resources (resources.json on the server)

Declare it as a system component so it is instantiated when the server process starts. In the long-lived parent process the handler is registered on SYSTEM_START and remains active across jobs. In per-job server subprocesses (where SYSTEM_START does not fire) the same instance re-registers on every START_RUN against the new job-scoped ObjectStreamer.

The stream handler may be (re-)registered on every triggering event; registry.set is idempotent for the same channel/topic pair.

Parameters:
  • dest_dir – directory where incoming log files are written. Defaults to the system temporary directory.

  • idle_timeout – seconds without any message (data or heartbeat) before the receiver declares the sender dead and closes the stream (default 30.0). Set to 0 to disable.

Init the Widget.