BTP Application Logging Part 2: Configuring and Consuming Logging on Cloud Foundry
Preview · a free account unlocks the full lesson
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 sectionsHide sections
Visual overview
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.
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
Interview questions on this topic
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.