Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 

It's a good approach for ABAPers to learn new technology like Open-Source tool by comparing them with the good-old stuff in Netweaver available many years ago.

The aim of this blog is to give you a brief introduction how to do logging in your application code and view those logs via Kibana. Before start, let's recall how the same requirement is done in ABAP.

Logging in Netweaver

There are several logging mechanisms available in Netweaver, for example application log or checkpoint supported by ABAP language itself.

Since this blog is not a cookbook for ABAP logging, I will not list detailed step but only give some higlight. In order to do logging in your application code, you need to use a standard or create your own checkpoint group via tcode SAAB. I personally treat this checkpoint group as the application log instance to be created in SAP Cloud Platform soon.

Here I use the standard checkpoint group DEMO_CHECKPOINT_GROUP.

Press "Display <->Activate" to enter edit mode, set Logpoints as "Log", date field as "Today", meaning the log only takes effect within today.

Create a configuration for user on whom the log must be switched on.

Create a report with name ZCONTEXT, and log the value of system variable sy-cprog and reporting running mode(online or offline, stored in sy-batch) into the standard checkpoint group.

Execute the report and go back to tcode SAAB to see the expected log record.

CloudFoundry environment in SAP Cloud Platform

The official guideline is documented in SAP Github.

It is recommended to use slf4j(Simple Log Facade for Java). As it name hints, slf4j works as an interface to provide log functionality; the concrete logging implementation could be decided by developers based on project requirement.

I have built a simple example and upload it to my github to demonstrate how to use logging. In my example I use log4j2 as slf4j implementation.

1. define version of slf4j and log4j2 in pom.xml of Java project.


Maintain dependency for slf4j and log4j2 in pom.xml as well:



2. Create log4j2.xml file in CLASSPATH folder( resources folder in my case):

<Configuration status="warn" strict="true"
<Console name="STDOUT-JSON" target="SYSTEM_OUT" follow="true">
<JsonPatternLayout charset="utf-8" />
<Console name="STDOUT" target="SYSTEM_OUT" follow="true">
pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} [%mdc] - %msg%n" />
<!-- Jerry: Log level: INFO -->
<Root level="${LOG_ROOT_LEVEL:-INFO}">
<AppenderRef ref="STDOUT-JSON" />
<Logger name="" level="${LOG_HCP_CF_LEVEL:-INFO}" />

3. Create a new log instance ( do you still remember the checkpoint group in ABAP? ) in SCP Cockpit:

I name it as "jerry-log":

4. use slf4j API for logging:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

private static final Logger LOGGER = LoggerFactory.getLogger(ConnectivityServlet.class);​

In my example, I log the connection detail for ABAP On-Premise system in my code:

5. Log monitoring

Click Logs tab in Cockpit, press button "Open Kibanna Dashboard", and the corresponding log record for the connection detail mentioned in step 4 is visible there.

The log instance "jerry-log" created in step 3 is also listed in the log detail message.

1 Comment