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 :
- Open the Command Palette prompt (⇧⌘P).
- Type in the
Watch nginx
command. - Select either the NGINX
access.log
orerror.log
value. (e.g.Watch nginx access.log
). - 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:
- Selecting the VS Code option labeled “Manage“, represented by a gear wheel icon at the bottom left.
- Select “Settings” from the flyout menu.
- Select the tab labeled “User”.
- Either select “Log Watcher” from the list of extensions, or type “Log Watcher” in the search field to access settings options.
- Disable the option to “Automatically Show Changes”.
Last updated: April 05, 2024