ERPClimb logoERPClimb
Application Logging
BTP & Integrationintermediate 5 min read

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

Preview · a free account unlocks the full lesson

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.

In this lessonShow sections

Visual overview

CONFIGURATIONAdding logging to a CF appService, library, levels, protection1Logging resource in MTAService instance created and boundmta.yaml2Logging libraryStructured JSON with correlation IDcds.log3Levels per environmentDEBUG dev, INFO/WARN prodLevels?Sensitive data?Personal data, tokensYes → mask or removeNoSearchable logsDashboard ready for supportDashboardTip: reset DEBUG levels after incidents to control cost.

Explanation

Part 1 explained logging conceptually; this lesson covers actually configuring and consuming it on Cloud Foundry. The starting point is creating a logging service instance and binding it to your applications, ideally declared as an MTA resource so it's part of the same deployment.

SAP's own logging libraries for Java and Node.js, or CAP's built-in logger, produce structured output that includes correlation IDs, which makes tracing a request across services much easier. Log levels should be adjusted per environment, and the ability to change log levels dynamically is particularly useful during an active incident, when you need more detail without redeploying.

Personal data and secrets should be masked or avoided in logs entirely, rather than relying on after-the-fact cleanup. Service plans differ in their retention period and allowed volume, so the right plan should be chosen based on actual need, with consumption monitored over time.

In CAP specifically, using cds.log with named components makes logs filterable by service, which is a small habit that pays off quickly. A real cost risk is leaving a DEBUG level that was raised temporarily for troubleshooting still active in production, since that floods both storage and cost over time.

In practice, this means adding a logging resource to mta.yaml, using the logging library inside the application, and deploying it to check the resulting logs in the dashboard — the goal being structured logs with correlation IDs that are actually visible and usable.

Free account

Create a free account to keep reading

You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.

  • Code example
  • Real project scenario
  • Common mistakes
  • Best practices
  • Interview angle

One tap with Google works too. Every topic keeps its first lesson open to everyone.

Keep exploring

Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.