我正在使用 com.sap.cloud.sdk.cloudplatform.logging.CloudLoggerFactory 进行日志记录。
如果我在本地 Java Web Tomcat8 服务器(Neo 运行时)上运行应用程序,日志将按预期显示在控制台中。
在 SAP Cloud Platform (SAP Neo Java Web Tomcat8) 中运行应用程序后,我只能看到应用程序启动阶段的日志(spring boot 横幅等),但看不到运行时的日志。
有任何想法吗?
更多信息:
在 pom.xml 中,我从工件中排除了 logback-classic 和 slf4j-api,它也提供了它们:
<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>
在 src/main/resources 下,我提供了一个 logback.xml,输出到 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>
运行时的记录器配置:我已将 ROOT 设置为“INFO”,将我的命名空间和其他一些设置为“TRACE”。
期望是,我使用 logger.info/logger.error/logger.debug 等发布的日志被写入。但是,在 SAP SCP Cockpit 中,仅写入 HTTP 访问日志和垃圾收集日志。“Other Logs”包括启动阶段的日志,但是在服务器启动之后,就不会再写其他的了。“默认跟踪”填充了一些或多或少的空跟踪。