Application Logging
BTP & Integrationintermediate

BTP Application Logging Part 2: Configuring and Consuming Logging on Cloud Foundry

Key takeaway

Set up logging for Cloud Foundry apps: create and bind the logging service instance (via MTA), use SAP logging libraries for Java and Node. js to produce structured logs, set log levels dynamically, mask sensitive data, and manage retention and cost.

Explanation

📌 KEY POINTS
✅ Create a logging service instance and bind it to apps (preferably as an MTA resource).

✅ Use SAP logging libraries (Java/Node.js) or CAP's built-in logger for structured output with correlation IDs.

✅ Adjust log levels per environment; dynamic log level changes help during incidents.

✅ Mask or avoid personal data and secrets.

⚠️ Service plans differ in retention and volume — choose by need and monitor consumption.

━━━━━━━━━━━━━━━━━━━━
▶ WHERE WE ARE

Part 1 explained logging. Now configuration.

━━━━━━━━━━━━━━━━━━━━
▶ 1. SERVICE INSTANCE

  • Plan choice; MTA resource.

━━━━━━━━━━━━━━━━━━━━
▶ 2. LIBRARIES

  • Java/Node.js support libraries; CAP logger.

━━━━━━━━━━━━━━━━━━━━
▶ 3. LEVELS

  • Per environment; dynamic changes.

━━━━━━━━━━━━━━━━━━━━
▶ 4. DATA PROTECTION

  • Masking; no tokens.

━━━━━━━━━━━━━━━━━━━━
▶ 5. COST & RETENTION

  • Plan limits; volume monitoring.

━━━━━━━━━━━━━━━━━━━━
▶ STEP BY STEP

  1. Add a logging resource to mta.yaml.
  2. Use the logging library in the app.
  3. Deploy and check logs in the dashboard.

✅ CHECKPOINT: structured logs with correlation IDs visible.

Code example

ABAP Code
===== mta.yaml resource (example) =====resources:  - name: orders-logs    type: org.cloudfoundry.managed-service    parameters: { service: application-logs, service-plan: standard }modules: requires: [ { name: orders-logs } ] ===== CAP (Node.js) =====const LOG = cds.log('orders')LOG.info('Order created', { orderId })LOG.error('Save failed', err)

Real project scenario

A company wanted to ensure sensitive data never appeared in logs. A code review found customer emails logged at DEBUG. Adding masking helpers and level policies per environment fixed compliance.

Common mistakes

  • DEBUG left on.
  • Emails/tokens in logs.
  • Manual service creation.
  • Wrong plan.
  • No component names.

Best practices

  • Levels by env.
  • Masking.
  • MTA resources.
  • Plan by volume.
  • Component loggers.

Interview angle

Questions: "How do you add logging to a CF app?", "How do you avoid sensitive data in logs?", "How do you control log costs?"
Strong answer: service/binding, libraries, levels, protection, cost.

Practice this lesson

Quick check

1. A company wants to ensure that sensitive customer data in message payloads is never persisted in the Message Processing Log, regardless of the log level set on individual integration flows. Which capability addresses this requirement?

2. When a new integration flow is deployed in SAP Cloud Integration without explicitly changing its logging configuration, what is the default log level applied to it?

3. An integration developer wants to add a custom entry to the Message Processing Log (MPL) from within a Groovy script so it appears alongside standard log steps in the Monitor Message Processing view. Which object should the script use to achieve this?

Interview questions

1. What are the most important design decisions, trade-offs, and best practices in Application Logging?

Answer it in your own words first, then compare.

2. Configure logging for a CAP application on Cloud Foundry.

Answer it in your own words first, then compare.

Practice more with Interview AI →

Reference-verified: the steps are checked against official SAP documentation and tutorials, and object and field names in the sample code are checked for consistency. The code has not been compiled or run on an SAP system by ERPClimb. Syntax marked release-dependent varies by SAP release, so check it in your own system.

More lessons in this topic

Interview questions on this topic

Related SAP topics