Retrieve Runtime Logs with VIP-CLI
Runtime Logs provides an aggregated, near real-time view into recent application logs generated by WordPress and Node.js applications on VIP Cloud. These logs provide insights into the current health of an environment and can be helpful for debugging issues.
- For WordPress applications, Runtimes Logs reports PHP errors including fatals, warnings, and notices (depending on the
error_reporting
level defined for an application) as well as any logs that are output using theerror_log()
function. - For Node.js applications, Runtime Logs retrieves output sent to
stdout
orstderr
, which is most commonly handled by theconsole
class.
Runtime Logs can also be reviewed in the Health panel of the VIP Dashboard.
Prerequisites
- VIP-CLI is installed and has been updated to the most current version.
- Retrieving Runtime Logs for an application requires a user to have at minimum an Org member role or an App write role for that application.
Example output of the Runtime Logs VIP-CLI command for a WordPress environment:
$ vip @mytestsite.production logs 2022-01-05T21:37:11.159495287Z PHP message: Warning: Division by zero in /var/www/wp-content/client-mu-plugins/errors.php on line 4 [mytestsite.go-vip.net/?warning=1] [wp-content/mu-plugins/z-client-mu-plugins.php:119 include_once('wp-content/client-mu-plugins/errors.php'), wp-settings.php:340 include_once('wp-content/mu-plugins/z-client-mu-plugins.php'), wp-config.php:53 require_once('wp-settings.php'), wp-load.php:50 require_once('wp-config.php'), wp-blog-header.php:13 require_once('wp-load.php'), index.php:17 require('wp-blog-header.php')] 2022-01-05T21:37:15.683692218Z PHP message: PHP Fatal error: Uncaught Error: Call to undefined function invalid_function() in /var/www/wp-content/client-mu-plugins/errors.php:8 2022-01-05T21:37:15.683720541Z Stack trace: 2022-01-05T21:37:15.683723928Z #0 /var/www/wp-content/mu-plugins/z-client-mu-plugins.php(119): include_once() 2022-01-05T21:37:15.683727274Z #1 /var/www/wp-settings.php(340): include_once('/var/www/wp-con...') 2022-01-05T21:37:15.683730831Z #2 /var/www/wp-config.php(53): require_once('/var/www/wp-set...') 2022-01-05T21:37:15.683733847Z #3 /var/www/wp-load.php(50): require_once('/var/www/wp-con...') 2022-01-05T21:37:15.683736782Z #4 /var/www/wp-blog-header.php(13): require_once('/var/www/wp-loa...') 2022-01-05T21:37:15.683739788Z #5 /var/www/index.php(17): require('/var/www/wp-blo...') 2022-01-05T21:37:15.683743695Z #6 {main} 2022-01-05T21:37:15.683746701Z thrown in /var/www/wp-content/client-mu-plugins/errors.php on line 8
Considerations
- Logs are aggregated from across multiple containers, then grouped by container and ordered by timestamp. This may cause multiline log entries to be returned in an unexpected order.
- Runtime Logs fetches raw logs from containers. An environment’s containers—and its logs—are replaced with new containers when a deployment is made. Only the logs on a current set of containers are retrievable.
- Logs are not guaranteed to persist for any length of time and will be cleared as needed. Applications that generate high volumes of logs will be cleared more often.
Command options
VIP-CLI command: vip logs [options]
By default, logs are output to the terminal, but the command output can also be saved to a file using tee
or >
.
Format of the vip logs
command with available options:
vip logs @<app>.<env> [--type=app|batch] [--limit=<lines>] [--format=text|json|csv]
--type
Accepted values: app
or batch
Default value: app
Indicates the type of logs to be retrieved. app
retrieves logs from web containers (i.e. log entries generated by HTTP requests) and batch
retrieves logs from batch containers (i.e. log entries generated by cron tasks or WP-CLI commands).
--limit
Accepted values: numerical value of lines to retrieve
Default value: 500
, maximum of 5000
Indicates how many log lines to fetch in a single command.
--format
Accepted values: text
, json
, or csv
Default value: text
Indicates the format that the returned logs will be rendered in the terminal.
--follow
Accepted values: none
When running vip logs --follow
, new log entries are automatically retrieved without needing to re-run the vip logs
command. This option is useful for tools that ingest logs for long term storage and analysis (e.g. Splunk or ELK). Because logs do not persist on containers, there is no guarantee that all log entries will be received. Review the Considerations above for more details.
Troubleshooting
No logs found
If a new deployment was made recently, wait a few seconds for logs to regenerate on the containers.
Error: Resource not found
A value used in the vip logs
command to target an application or the environment may be incorrect, or the user running the command does not have the required minimum of Org member role or App write role to retrieve logs for that application.
Error: Too many requests, please try again in [] seconds.
Log requests are rate limited per-user and per-application. Wait the recommended amount of time provided in the error message before attempting a new request.
Last updated: December 23, 2022