TeamCity Cloud 2023.11 Help

Build Log

A build log is an enhanced console output of a build. It is represented by a structured list of the events which took place during the build. Generally, it includes entries on TeamCity-performed actions and the output of the processes launched during the build. TeamCity captures the processes output and stores it in an internal format that allows for hierarchical display.

Viewing Build Log

To view the full log details, navigate to the Build Results page and switch to the Build Log tab. In this tab, you have the following options for viewing the log:

  • Expand All — expands all nested log messages.

  • Collapse All — collapses all nested log messages.

  • View filter — defaults to All Messages. You can use this button to filter for errors or important messages. You can also select the Verbose mode to see the most fine-grained logging level.

  • Enable soft-wrap lines — wrap the log lines in the build log panel.

  • Enable relative time — show timestamp values relative to the build start time, instead of the absolute time.

You can download a full build log in the textual form or as a .zip archive by clicking the Download log dropdown and selecting the required format.

Integration with Log Analysis Tools

If you want 3rd-party log analysis tools to ingest logs generated by TeamCity builds, set up the integration that targets the following URL:

  • http(s)://<SERVER_URL>/downloadBuildLog.html?buildId=<ID> — if your log analysis tool authenticates in TeamCity using an access token.

  • http(s)://<SERVER_URL>/httpAuth/downloadBuildLog.html?buildId=<ID> — if the tool authenticates using the standard username/password credentials.

For example, a request to the following URL will result in downloading a log for a build whose internal ID is "4102":

http://localhost:8111/downloadBuildLog.html?buildId=4102

Note that build IDs are unique values that are not equal to build numbers. You can obtain a build ID from the build results page URL (the Integer value before the ?buildTab=... parameter).

Internal Build ID

To retrieve build IDs via REST API, send a request to the /app/rest/builds endpoint. You can use various locators to search for specific builds. For example, the following request returns builds that belong to the specific build configuration:

/app/rest/builds?locator=buildType:ProjectName_ConfigName

Additional URL Parameters

Obtain Build Log as Plain Text

A request to the http(s)://<SERVER_URL>/downloadBuildLog.html?buildId=<ID> URL returns a response with the Content-Disposition header set to "attachment":

Content-Disposition: attachment; filename*=UTF-8''ProjectName_ConfigName_BuildNumber.log;

This header forces modern browsers to download the required build log as an attachment. If you want to open the contents of a log in a browser tab without downloading it, append the &plain=true parameter to your URL. For example:

http://localhost:8111/downloadBuildLog.html?buildId=4102&plain=true

The contents of the target build log is available as plain text inside the response body.

Download Archived Log

Add the archived=true parameter to the URL to download the target log file as a .zip archive. For example:

http://localhost:8111/downloadBuildLog.html?buildId=4102&archived=true

Modify the DateTime Pattern

By default, timestamps in a build log are written in the "HH:mm:ss" format. You can add the dateFormat=<value> parameter to the URL to modify the DateTime pattern. Custom patterns must follow the Java SimpleDateFormat specification.

For example:

http://localhost:8111/downloadBuildLog.html?buildId=4102&dateFormat=yyyy-MM-dd%20HH%3Amm%3Ass%20zz

Customizing Log Output

You can modify the log output using service messages. This includes grouping the log entries in blocks, handling parallel message flows, changing the severity of a log message, and so on.

Build Log Size

It is recommended to keep the build log small and tune build scripts not to print too much into the output. Large build logs are hard to view in the browser and are loading TeamCity infrastructure piping build messages from the agent to the server while the build is running.

It is recommended to print into the output only the messages required to understand the build progress and build failures. The rest of the information should be streamed into a log file and the file should be published as a build artifact. A "good" build log size is megabytes at most.

Partial Build Log Display

When opening large build logs, TeamCity displays a part of it to avoid browser hanging. You can view the full build log on clicking the corresponding link.

The display threshold is set to 5M characters.

ANSI-style Coloring in Build Log

TeamCity build logs render clickable hyperlinks and support ANSI-style escape color codes by default: if your tool produces a colored console output, you will see in the build log in TeamCity. See the related feature request for the full list of supported sequences.

Last modified: 06 October 2023