2

Using latest version of Java SAP Cloud SDK

We have some code which uses ODataQueryBuilder API and VDM API as well. We want to log the HTTP requests that are being sent by these API's. We want to log whole of the HTTP request - headers, body everything. Please note that our application is running on SAP Cloud Platform's Cloud Foundry PAAS offering and using cf set-logging-level doesn't seem to work.

cleancoder
  • 162
  • 1
  • 10
  • What is the application based on? Spring or TomEE? Are you aware of any log implementation provided by you application? – Alexander Dümont Apr 01 '20 at 15:20
  • It's a TomEE application (SAP CAP Application). We use sl4j for logging with logback binding. – cleancoder Apr 01 '20 at 15:52
  • To be precise we use https://github.com/SAP/cf-java-logging-support which uses the things I've mentioned in my previous comment. – cleancoder Apr 01 '20 at 16:02
  • Can you check whether the following works for you...? [Developing Java in the Cloud Foundry Environment / Logging and Tracing](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/7eb922a1668a435d8bd681263e0be12e.html) – Alexander Dümont Apr 01 '20 at 16:52
  • No it doesn't. I've already mentioned it in my question. It works for all our applcation logs but doesn't work for `ODataQueryBuilder` API and VDM API. – cleancoder Apr 02 '20 at 04:13

2 Answers2

0

I've been using this Java arg when debugging my requests, but I've been doing it locally.

-Dorg.slf4j.simpleLogger.log.org.apache.http.wire=debug

If you can pass it withing CF environment I think you should start seeing all the payloads. I'll research a bit more to provide a better guidance if this won't work for you.

Artyom Kovalyov
  • 374
  • 3
  • 11
  • Unfortunately, I've already tried this approach. I have been able to pass it to CF environment, but the requests from `ODataQueryBuilder` API and VDM API don't get logged. – cleancoder Apr 01 '20 at 14:17
  • Can you post here how you currently pass it? Is it a Spring or Tomee application? – Artyom Kovalyov Apr 01 '20 at 14:24
  • It's a Tomee application (SAP CAP Application). We use sap_java_buildpack and any command line arguments to JVM can be passed by specifying them in JBP_CONFIG_JAVA_OPTS variable. Here is a sample value for this variable - [java_opts: '-DyourEnvVar -anotherVar'] – cleancoder Apr 01 '20 at 15:44
0

For applications deployed on SCP CF, there are different setups for which recommend other logging practices. The goal is to configure individual log levels for specific packages of your application and third-party dependencies, e.g. SAP Cloud SDK or SAP Service SDK or Apache HTTP components.

TomEE based application:

  • Edit the manifest.yml to include the following env entry for environment variable:
    SET_LOGGING_LEVEL: '{ROOT: INFO, com.sap.cloud.sdk: INFO, org.apache.http.wire: DEBUG}'
    
    Feel free to customize.

Spring Boot based application:

  • We expect the logback framework.
  • Edit/Create the file: application/src/main/resources/logback-spring.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <springProfile name="!cloud">
            <include resource="org/springframework/boot/logging/logback/base.xml"/>
            <root level="INFO"/>
            <logger name="org.springframework.web" level="INFO"/>
        </springProfile>
    
        <springProfile name="cloud">
            <appender name="STDOUT-JSON" class="ch.qos.logback.core.ConsoleAppender">
                <encoder class="com.sap.hcp.cf.logback.encoder.JsonEncoder"/>
            </appender>
            <logger name="org.springframework.web" level="INFO"/>
            <logger name="com.sap.cloud.sdk" level="INFO"/>
            <logger name="org.apache.http.wire" level="DEBUG"/>
            <root level="INFO">
                <appender-ref ref="STDOUT-JSON"/>
            </root>
        </springProfile>
    </configuration>
    

    Feel free to customize.

  • Notice the different profile settings. Make sure the cloud profile is active for deployed applications. Edit the manifest.yml to include the following env entry for environment variable:
    SPRING_PROFILES_ACTIVE: 'cloud'
    
Alexander Dümont
  • 903
  • 1
  • 5
  • 9