nvflare.app_common.logging.site_log_streamer module

class SiteLogStreamer(log_file_name: str = 'log.txt', liveness_interval: float = 10.0, poll_interval: float = 0.5)[source]

Bases: Widget

Site-level widget that injects a JobLogStreamer into every job that does not already declare one.

Place this in the client’s resources.json so that live log streaming is provided automatically for every job — without requiring each job to include a JobLogStreamer in its own configuration.

On BEFORE_JOB_LAUNCH (after the job config is deployed to disk but before the job subprocess starts) SiteLogStreamer reads the deployed config_fed_client.json. If no JobLogStreamer component is found, it appends one with the configured parameters and writes the file back. The job subprocess then picks up the modified config and JobLogStreamer runs inside the job as if the user had declared it explicitly.

When configured for error_log.txt, SiteLogStreamer also uploads a post-run snapshot from CLIENT_PARENT on JOB_COMPLETED. This preserves error-log delivery for launch/config/bootstrap failures where the job subprocess never reaches START_RUN and therefore never loads the injected JobLogStreamer.

The server side must have a JobLogReceiver in its resources.json (or job config) to receive and store the stream.

Parameters:
  • log_file_name – base name of the log file to stream. Defaults to WorkspaceConstants.LOG_FILE_NAME ("log.txt").

  • liveness_interval – seconds between heartbeat messages when no new log bytes have been written (default 10.0). Must be strictly less than the receiver’s idle_timeout.

  • poll_interval – seconds between polls when no new data has been written to the log (default 0.5).

Init the Widget.