If you have already started developing with Sitecore XM Cloud and looking to see how you could troubleshoot by looking into the logs then this article might be helpful.
In my previous article, I had mentioned that it would be nice to have live logs streamed to console but nonetheless you still have options to list/download & view Sitecore log files using Sitecore Cloud CLI commands. I have listed out all cli commands that are handy at the end of this article.
Viewing XM Cloud Logs
There are couple of ways to view XM Cloud logs. You can either use the UI to check them out or Sitecore Cloud CLI to download and view it.
Using XM Cloud Portal
Using the portal, navigate to Environments of specific project using Manage Projects link. You would be redirected to deploy.sitecorecloud.io where you can see all the environments associated to a project. Choose options and click on ‘View Environment Logs’ for a specific environment that you would like to check the logs.
You would then see the logs organized based on names including that for Rendering hosts.
You can then click on anyone of these logs and you’ll notice that they are organized based on last modified date. Simply clicking on the link will open up the log file in the browser.
Using Sitecore Cloud CLI
We can also use Sitecore Cloud CLI commands to view the logs. It is similar to that of the portal and helps you to quickly download a log file.
dotnet sitecore cloud environment log -h
Listing Logs in XM Cloud
You can use ‘list command together with below options to get the log listed. The only mandatory param is Environment Id.
dotnet sitecore cloud environment log list -id <environment-id> --latest
Viewing log file
If you would like to checkout the log file, you can simply execute below command that will show to contents of the log file in the terminal.
dotnet sitecore cloud environment log view -id <environment-id> --log <log-file-name>
You can alternatively download file and view it using the below command.
dotnet sitecore cloud environment log download -id <environment-id> --log <log-file-name> -o <outputpath>
Sitecore Cloud CLI offers command to view deployment logs. Which is very useful when you would like to check deployment issues.
dotnet sitecore cloud deployment log -h
You can download the logs to an output folder using below command.
dotnet sitecore cloud deployment log -id <environment-id> -o <output-path> -v -t
Sitecore Logs CLI Cheat Sheet
|dotnet sitecore cloud environment log -h||Environment Log help.|
|dotnet sitecore cloud environment log list -id <environment-id> –latest||Listing out latest logs for a specific environment.|
|dotnet sitecore cloud environment log view -id <environment-id> ||Viewing environment log in terminal.|
|dotnet sitecore cloud environment log download -id <environment-id> ||Downloading a log file to specific path.|
|dotnet sitecore cloud deployment log -h||Deployment log help.|
|dotnet sitecore cloud deployment log -id <environment-id> ||Downloading deployment log to a specific path.|
Sitecore XM Cloud official documentation – https://doc.sitecore.com/xmc/en/developers/xm-cloud/the-cli-cloud-command.html