SAP BTP cockpit allows accessing only the last 1000 lines of logs. Sometimes it's enough for debugging but in most cases, it's not. So there is a way to download all needed logs directly from the app.
First of all, you need to execute next two commands:
- cf enable-ssh APP-NAME
- cf restart APP-NAME
Enable-ssh and restart should be executed only once here. If ssh is already enabled, you don't need to repeat these steps again. Unfortunately, the file system (including the logs) got recreated after restarting of the application. In other words, it means that you will be able to download only the logs recorded after the previous restart.
You need to proceed with the following commands:
- cf app APP-NAME --guid
- cf curl /v2/info
- cf ssh-code
Then you can connect to the application. If you are a Windows user, it's easy to use WinSCP program with the following parameters:
File protocol: SFTP
Host name and port: copy from "app_ssh_endpoint" field of the 4th command.
User name: cf:APP-GUID/0 where APP-GUID is a result of the 3rd command.
Password: result of the 5th command.
This ssh code is valid for a short period of time. So execute cf ssh-code again if the code is expired.
For example:
Then you can open /logs folder and download the files to your local computer.