How to record and view logs in ABAP NetWeaver and Cloudfoundry

Source: Internet
Author: User

Netweaver

To log logs you need to have a checkpoint group that you can create yourself or use the standard. Here I reuse the standard group:demo_checkpoint_group.

Tcode SAAB, point display <->activate into the editing mode, the logpoints is set to "Log", the date is set to today, meaning the day effective.

NetWeaver's log records are mostly user-level based, which is a bit more convenient. Create a configuration to open the log switch for the user who wants to open the log record:

Creating a new report name is called Zcontext, and the following code means writing the current report name (included in the environment variable Sy-cprog) and the current report's run environment (online or offline) to the checkpoint Group Because there may be other people who use the group, the subkey distinguishes between different users.

LOG-POINT ID demo_checkpoint_groupSUBKEY sy-unameFIELDS sy-batch sy-cprog.


Return to Saab after the report has been executed to see the log of the record.

Double-click to see the details of the record.

Cloudfoundry

The total guideline is on SAP's official GitHub.

Here is a brief outline.

Log records in the Cloudfoundry environment of the SAP Cloud Platform recommend the use of slf4j (simple log facade for Java). That is, the Java code uses the interface provided by the SLF4J for logging, and the specific logging implementation can be specified through a configuration file.

I made an example of all the source code on my github.
My example uses Log4j2 as a log record implementation.

(1) Define the version number of SLF4J and LOG4J2 in the Java project's pom.xml.

<properties>  <maven.compiler.source>1.8</maven.compiler.source>  <maven.compiler.target>1.8</maven.compiler.target>  <cf-logging-version>2.1.5</cf-logging-version>  <log4j2.version>2.8.2</log4j2.version>  <slf4j.version>1.7.24</slf4j.version></properties>

Maintain related dependency in the dependency area of the Pom.xml file:

<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> < Version>${slf4j.version}</version></dependency><dependency> <groupId> Com.sap.hcp.cf.logging</groupid> <artifactId>cf-java-logging-support-log4j2</artifactId> < Version>${cf-logging-version}</version></dependency><dependency> <groupId> Org.apache.logging.log4j</groupid> <artifactId>log4j-slf4j-impl</artifactId> <version>${ Log4j2.version}</version></dependency><dependency> <groupid>org.apache.logging.log4j </groupId> <artifactId>log4j-core</artifactId> <version>${log4j2.version}</version ></dependency><dependency> <groupId>com.sap.hcp.cf.logging</groupId> <artifactid >cf-java-logging-support-servlet</artifactId> <version>${cf-logging-version}</version>< /dependency> 

(2) Create a new log4j2.xml under Classpath, using the following source code:

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

(3) Create a new log instance in the SAP Cloud Platform cockpit:


Named as Jerry-log:

(4) Use in the code:

import org.slf4j.Logger;import org.slf4j.LoggerFactory;private static final Logger LOGGER = LoggerFactory.getLogger(ConnectivityServlet.class);

Then use Logger.info to log the logs.

(5) How to query the log of records:
Click the Logs tab->open Kibanna Dashboard to see the log for Diablo connecting to backend system:

The Log service instance created earlier in the SAP cloud platform cockpit can be seen in the log details.

To get more original Jerry's technical articles, please follow the public number "Wang Zixi" or scan the QR code below:

How to record and view logs in ABAP NetWeaver and Cloudfoundry

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.