Skip to content

Access logs for GitHub Codespaces

Log error files for a GitHub Codespace environment can be accessed in the terminal of the Visual Studio Code interface.

Access the logs with Linux prompts such as less, cat, tail or grep depending on a user’s needs. This example command demonstrates how to access the NGINX access logs of a running codespace environment with less:

less /var/log/nginx/access.log

To review log output in real time, include the -f (“follow”) parameter with the tail command. This example command demonstrates how to access and stream the NGINX/PHP error logs of a running codespace environment with tail -f:

tail -f /var/log/nginx/error.log
  • NGINX access log: /var/log/nginx/access.log
  • NGINX/PHP error log: /var/log/nginx/error.log

Visual Studio Code extensions for log access

The Automattic-authored VS Code Log Watcher extension and the VS Code Log File Highlighter extension are installed and enabled by default in the GitHub Codespaces environment. The Log Watcher extension simplifies the steps needed to access log files and output them in real time.

Access a log file :

  1. Open the Command Palette prompt (⇧⌘P).
  2. Type in the Watch nginx command.
  3. Select either the NGINX access.log or error.log value. (e.g. Watch nginx access.log).
  4. Confirm the selection by pressing Enter or Return.

Contents of the requested log will be displayed in real time in the tab labeled “Output“.

Option to automatically show changes

By default, when a watched file is updated, Log Watcher will shift focus to that file in the “Output” tab. This behavior can be disabled by:

  1. Selecting the VS Code option labeled “Manage“, represented by a gear wheel icon at the bottom left.
  2. Select “Settings” from the flyout menu.
  3. Select the tab labeled “User”.
  4. Either select “Log Watcher” from the list of extensions, or type “Log Watcher” in the search field to access settings options.
  5. Disable the option to “Automatically Show Changes”.

Last updated: April 05, 2024

Relevant to

  • WordPress