Retrieve the Application Logs

You may want to check your application logs to monitor the application or troubleshoot a problem. Information that your application sends to stdout or stderr is captured in the logs. The logs are stored on Oracle Cloud Infrastructure Object Storage Classic. You can download the logs using the user interface console, the command-line interface or the REST API.

Using the User Interface Console

To learn how to get your application’s logs by using the Oracle Application Container Cloud Service console, see Retrieving the Application Logs in Using Oracle Application Container Cloud Service

Using the Command-line Interface

To download the logs by using the command-line interface first you need to generate the logs by using the psm accs get-logs command then you can get the logs of each instance with the psm accs log command or all of them with the psm accs logs command.

Example 5-1 Generating the Logs for the Application

psm accs get-logs -n employees-app -i web.1 -of json

Example 5-2 Getting the Logs for the web.1 Instance

psm accs log -n employees-app -i web.1 -of json

Example 5-3 Getting the Logs for all Instances

psm accs logs -n employees-app -of json

To get more information about the psm accs commands, see psm accs Commands in PaaS Service Manager Command Line Interface Reference

Using the REST API to Retrieve a Log

To download the log for an application from Oracle Cloud Infrastructure Object Storage Classic, use the following command as a reference. You will need the cURL utility and the storage service information that you received when you subscribed to the service.

First you will need an authentication token. Here’s an example of a cURL command for requesting an authentication token:

Example 5-4 Requesting an Authentication Token

curl -v -X GET \	
     -H "X-Storage-User: myService-myIdentityDomain:myUsername" \  
     -H "X-Storage-Pass: myPassword" \  	
     https://storage.us2.oraclecloud.com/auth/v1.0

After you have the token, you can request the log, as in this example:

Example 5-5 Requesting the Logs

curl -v -X GET \
     -H "X-Auth-Token: AUTH_tkb4fdf39c92e9f62cca9b7c196f8b6e6b" \
     -o destinationFileName \
     https://storage.us2.oraclecloud.com/v1/Storage-myIdentityDomain/myContainer/myApplicationLog

To learn more about the Oracle Cloud Infrastructure Object Storage Classic REST API, see REST API for Standard Storage in Oracle Storage Cloud Service.