doc/ci/jobs/job_logs.md
{{< details >}}
{{< /details >}}
A job log displays the full execution history of a CI/CD job.
To view job logs:
To view detailed information about the job and its log output, scroll through the job logs page.
{{< history >}}
{{< /history >}}
You can view the contents of a job log in full screen mode by clicking Show full screen.
To use full screen mode, your web browser must also support it. If your web browser does not support full screen mode, then the option is not available.
{{< history >}}
FF_SCRIPT_SECTIONS. Disabled by default.{{< /history >}}
[!flag] The availability of this feature is controlled by a feature flag. For more information, see the history.
When FF_SCRIPT_SECTIONS is enabled, multi-line script commands appear as collapsible sections
in job logs. Single-line commands are printed directly with a $ prefix. Durations are not
displayed.
In powershell and pwsh shells, FF_SCRIPT_SECTIONS does not create collapsible sections.
Commands are printed with color output only.
You can create collapsible sections in job logs by manually outputting special codes that GitLab uses to delimit collapsible sections:
\e[0Ksection_start:UNIX_TIMESTAMP:SECTION_NAME\r\e[0K + TEXT_OF_SECTION_HEADER\e[0Ksection_end:UNIX_TIMESTAMP:SECTION_NAME\r\e[0KYou must add these codes to the script section of the CI configuration.
For example, using echo:
job1:
script:
- echo -e "\e[0Ksection_start:`date +%s`:my_first_section\r\e[0KHeader of the 1st collapsible section"
- echo 'this line should be hidden when collapsed'
- echo -e "\e[0Ksection_end:`date +%s`:my_first_section\r\e[0K"
The escape syntax may differ depending on the shell that your runner uses.
For example if it is using Zsh, you may need to escape the special characters
with \\e or \\r.
In the example above:
date +%s: Command that produces the Unix timestamp (for example 1560896352).my_first_section: The name given to the section. The name can only be composed
of letters, numbers, and the _, ., or - characters.\r\e[0K: Escape sequence that prevents the section markers from displaying in the
rendered (colored) job log. They are displayed when viewing the raw job log, accessed
in the upper-right corner of the job log by selecting Show complete raw ({{< icon name="doc-text" >}}).
\r: carriage return (returns the cursor to the start of the line).\e[0K: ANSI escape code to clear the line from the cursor position to the end of the line.
(\e[K alone does not work; the 0 must be included).Sample raw job log:
\e[0Ksection_start:1560896352:my_first_section\r\e[0KHeader of the 1st collapsible section
this line should be hidden when collapsed
\e[0Ksection_end:1560896353:my_first_section\r\e[0K
Sample job console log:
To remove the echo statements that create the section markers from the job output,
you can move the job contents to a script file and invoke it from the job:
Create a script that can handle the section headers. For example:
# function for starting the section
function section_start () {
local section_title="${1}"
local section_description="${2:-$section_title}"
echo -e "section_start:`date +%s`:${section_title}[collapsed=true]\r\e[0K${section_description}"
}
# Function for ending the section
function section_end () {
local section_title="${1}"
echo -e "section_end:`date +%s`:${section_title}\r\e[0K"
}
# Create sections
section_start "my_first_section" "Header of the 1st collapsible section"
echo "this line should be hidden when collapsed"
section_end "my_first_section"
# Repeat as required
Add the script to the .gitlab-ci.yml file:
job:
script:
- source script.sh
To collapse sections by default, add [collapsed=true]
to the section start marker, after the section name, and before the \r:
[collapsed=true]: \e[0Ksection_start:UNIX_TIMESTAMP:SECTION_NAME[collapsed=true]\r\e[0K + TEXT_OF_SECTION_HEADER\e[0Ksection_end:UNIX_TIMESTAMP:SECTION_NAME\r\e[0KAdd the updated section start text to the CI configuration. For example,
using echo:
job1:
script:
- echo -e "\e[0Ksection_start:`date +%s`:my_first_section[collapsed=true]\r\e[0KHeader of the 1st collapsible section"
- echo 'this line should be hidden automatically after loading the job log'
- echo -e "\e[0Ksection_end:`date +%s`:my_first_section\r\e[0K"
When you delete a job log you also erase the entire job.
For more details, see Delete job logs.
{{< details >}}
{{< /details >}}
{{< history >}}
parse_ci_job_timestamps. Disabled by default.parse_ci_job_timestamps removed in GitLab 17.2.{{< /history >}}
By default, job logs include timestamps in the ISO 8601 format for each line. Use timestamps to troubleshoot performance issues, identify bottlenecks, and measure how long specific build steps take.
When timestamps are enabled, the job log uses approximately 10% more storage space.
The following shows an example of a job log with timestamps:
Prerequisites:
To control whether timestamps appear in job logs, use the FF_TIMESTAMPS CI/CD variable:
false to disable timestampstrue to explicitly enable timestampsFor example:
variables:
FF_TIMESTAMPS: false # Disables timestamps
job:
script:
- echo "This job's log behavior depends on FF_TIMESTAMPS value"
For more information, see define a CI/CD variable in the .gitlab-ci.yml file.
When you visit the job log page for a running job, there could be a delay of up to 60 seconds before a log update. The default refresh time is 60 seconds, but after the log is viewed in the UI one time, log updates should occur every 3 seconds.
This job does not have a trace in GitLab 18.0 or laterAfter upgrading a GitLab Self-Managed instance to 18.0 or later, you might see
This job does not have a trace errors. This could be caused by a failed upgrade migration
on an instance with both:
ci_enable_live_trace.
This feature flag is enabled by default in GitLab Environment Toolkit or Helm Chart deployments,
but could also be enabled manually.To restore the ability to view job logs on affected jobs, re-enable incremental logging