Reputation: 113
I am using com.sap.cloud.sdk.cloudplatform.logging.CloudLoggerFactory for logging.
The logs will be shown as expected in the console in case I run the application on a local Java Web Tomcat8 Server (Neo runtime).
Once I run the application inside the SAP Cloud Platform (SAP Neo Java Web Tomcat8), I see only the logs of the start up phase of the application (spring boot banner etc.), but not the logs during runtime.
Any ideas?
Further Information:
Within the pom.xml, I have excluded logback-classic and slf4j-api from artifacts, which provides them as well:
<dependencies>
<dependency>
<groupId>com.sap.cloud.s4hana.cloudplatform</groupId>
<artifactId>scp-neo</artifactId>
<version>${sapcloud.version}</version>
<exclusions>
<exclusion>
<groupId>com.sap.cloud.s4hana.frameworks</groupId>
<artifactId>hystrix-scp-neo</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sap.cloud.s4hana</groupId>
<artifactId>s4hana-all</artifactId>
<version>${sapcloud.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
</exclusion>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<exclusions>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-jpa-processor-api</artifactId>
<version>${olingo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-jpa-processor-core</artifactId>
<version>${olingo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-ref</artifactId>
<version>${olingo.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
Below src/main/resources, I have provided a logback.xml, output to STDOUT.
<configuration>
<conversionRule conversionWord="a" converterClass="com.sap.core.js.logging.converter.ACHPatternConverter"/>
<conversionRule conversionWord="b" converterClass="com.sap.core.js.logging.converter.BundleNamePatternConverter"/>
<conversionRule conversionWord="s" converterClass="com.sap.core.js.logging.converter.DSRPatternConverter"/>
<conversionRule conversionWord="z" converterClass="com.sap.core.js.logging.converter.SpaceApplPatternConverter"/>
<conversionRule conversionWord="u" converterClass="com.sap.core.js.logging.converter.UserPatternConverter"/>
<conversionRule conversionWord="o" converterClass="com.sap.core.js.logging.converter.UTFOffsetPatternConverter"/>
<jmxConfigurator/>
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>
Loggers Configuration during runtime: I have set ROOT to "INFO" and my namespace and some other to "TRACE".
The expectation is, that the logs, which I am issuing using logger.info/logger.error/logger.debug etc. are written. However, in the SAP SCP Cockpit only the HTTP Access logs and garbage collection logs are written. The "Other Logs" include the logging of the startup phase, but after the server has been started, nothing else will be written anymore. The "Default Traces" are filled with some more or less empty traces.
Upvotes: 1
Views: 651
Reputation: 158
In Neo the log level (for everything) is set to ERROR by default.
To be able to see other log levels you have to configure it in the SCP Cockpit while the application is running (started). (You won't see any loggers if the application is stopped)
In the SCP Cockpit, go to your Java application, then go to Logging and click Configure Loggers.
There's a good blog post about this here (see Adjust Cloud Log Level):
https://blogs.sap.com/2017/09/19/logging-on-sap-s4hana-cloud-sdk/
Upvotes: 2