Reading Logs & Environment Variables

Stream live logs from a deployed BTP app, read recent logs after a crash, and inspect environment variables to debug binding and config issues.

Reading Logs & Environment Variables on BTP

Once your app is deployed, the cf CLI is your window into what's happening in production.

List your apps

cf apps

Output:

name             requested state   instances   memory   disk   urls
bookshop-srv     started           1/1         256M     512M   bookshop-srv.cfapps.eu10.hana.ondemand.com
bookshop-app     started           1/1         128M     256M   bookshop.cfapps.eu10.hana.ondemand.com

Stream live logs

cf logs bookshop-srv

Every log line from your app appears in real time. Press Ctrl+C to stop.

Read recent logs (after a crash)

cf logs bookshop-srv --recent

This shows the last ~1000 log lines. Useful for finding the error that caused a crash.

Filter logs

cf logs bookshop-srv --recent | grep -i error
cf logs bookshop-srv --recent | grep "cds -"

Common log patterns

Log line Meaning
[APP/PROC/WEB] OUT [cds] - server listening on... App started successfully
[APP/PROC/WEB] ERR Error: connect ECONNREFUSED Can't reach a bound service
[CELL/0] OUT Exit status 137 App ran out of memory (increase memory in mta.yaml)
[STG/0] ERR npm ERR! ... Build failed during staging

Inspect environment variables

cf env bookshop-srv

This prints all environment variables, including:

{
  "VCAP_SERVICES": {
    "hana": [{
      "credentials": {
        "host": "...",
        "port": "443",
        "user": "DEPLOY_USER_...",
        "password": "..."
      }
    }],
    "xsuaa": [...]
  },
  "VCAP_APPLICATION": {
    "application_name": "bookshop-srv",
    "space_name": "dev"
  }
}

VCAP_SERVICES is how Cloud Foundry passes service credentials to your app. CAP reads this automatically — no manual wiring needed.

Check app events (crash history)

cf events bookshop-srv

Shows a timeline of start, stop, crash, and scale events.

Restart vs Restage

Command When to use
cf restart bookshop-srv App is hanging or unhealthy; same code, same env
cf restage bookshop-srv Environment variables changed (new binding, new env var)
cf push / cf deploy Code changed — need a new deployment

Scale up if the app keeps crashing

cf scale bookshop-srv -m 512M   # double the memory
cf scale bookshop-srv -i 2      # run 2 instances
Sign in for progress tracking & Q&A →