Categories:

System Functions (System Information)

SYSTEM$GET_JOB_LOGS

Retrieves local logs from a Snowpark Container Services job container.

See also:

Accessing container logs

Syntax

SYSTEM$GET_JOB_LOGS( <job_uuid>, <container_name> [ , <number_of_most_recent_lines> ]  )
Copy

Arguments

Required:

job_uuid

Snowflake-assigned UUID of the job. See Usage Notes in the EXECUTE SERVICE topic for instructions on finding the UUID.

container_name

Container name as specified in the job specification file.

Optional:

number_of_most_recent_lines

Number of most recent log lines to retrieve.

Default: Up to 100 KB of the most recent log lines.

Returns

Returns a string consisting of newline-separated log entries from the specified job container.

Usage notes

  • Only the user who created the job can access the logs from the job container.

  • The function returns a container log as a string. You can optionally use the SPLIT_TO_TABLE function to convert the string into a table containing one row for each newline-separated entry.

Examples

This function retrieves job logs from the “main” container of the specified job:

SELECT SYSTEM$GET_JOB_LOGS('01acc747-0000-60c0-0000-0e99001fd07a', 'main');
Copy

Sample output:

+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| SYSTEM$GET_JOB_LOGS( '01ACC747-0000-60C0-0000-0E99001FD07A', 'MAIN' )                                                                                               |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| job-tutorial - INFO - Job started                                                                                                                                   |
| job-tutorial - INFO - Connection succeeded. Current session context: database="TUTORIAL_DB", schema="DATA_SCHEMA", warehouse="TUTORIAL_WAREHOUSE", role="TEST_ROLE" |
| job-tutorial - INFO - Executing query [select current_time() as time,'hello'] and writing result to table [results]                                                 |
| job-tutorial - INFO - Job finished                                                                                                                                  |
|                                                                                                                                                                     |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+