⚠️ New in v0.28.0
This feature is new as of version
0.28.0and is currently in Beta.
When developing a load test, it's often useful to print messages for debugging purposes.
The k6 API supports the following console logging methods:
Logs can aid you in troubleshooting your test execution. But they should NOT replace the functionality of other k6 APIs.
For example, it is often an anti-pattern to use
- Track the status of a condition. Instead, use Checks to assert these conditions.
- Track a variable value during the test execution. Instead, use the Trend metric.
To develop and debug your load tests, we recommend, in most cases, running your tests locally - using the
When your script is ready, execute the test on the k6 Cloud with the
The Logs Tab allows you to view and filter log messages in the Cloud Results page.
In addition to the log messages, the log panel shows context information such as:
- Log date in the local time zone
- Load zone: the geographic zone where the load generator server is located
- Instance ID: numerical ID of the load generator server taking part in the test
See how the k6 Cloud injects environment variables for further information about the load zone and instance ID.
You can filter messages by severity level and load zone. The load zone filter is only present when your test has been executed in two or more load zones.
Logs are intended to help you in finding script issues and debugging execution anomalies. You should NOT rely on logging to interpret or analyze the performance of your system.
For this reason, the cloud logs have some limitations:
- The logs are deleted 3 days after the test execution.
- The number of log lines is limited to 10 messages per second per server. If this limit is crossed, a warning messages appears showing the number of discarded log lines.
k6 aims to have a consistent experience when running local and cloud tests.
When running cloud tests using the CLI (
k6 cloud), k6 will print cloud logs on the standard output as it does with your local tests.
If you don't want the cloud logs to be printed on the terminal, add the
Next, Test Comparison