We are using Paketo BuildPacks for our Spring Boot application. We configured all logs to be JSON written to STDOUT. The issue is that there’s a few lines of logs by Paketo during startup:
Setting Active Processor Count to 2 Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx1643814K -XX:MaxMetaspaceSize=146137K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 2G, Thread Count: 50, Loaded Class Count: 23387, Headroom: 0%) Enabling Java Native Memory Tracking Adding 124 container CA certificates to JVM truststore Spring Cloud Bindings Enabled Picked up JAVA_TOOL_OPTIONS: -Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -XX:+ExitOnOutOfMemoryError -XX:ActiveProcessorCount=2 -XX:MaxDirectMemorySize=10M -Xmx1643814K -XX:MaxMetaspaceSize=146137K -XX:ReservedCodeCacheSize=240M -Xss1M -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+PrintNMTStatistics -Dorg.springframework.cloud.bindings.boot.enable=true
Is there any way to configure Paketo to print the above as JSON:
{ timestamp: 1234567890, "app": "my-service", "message": "Setting Active Processor Count to 2" }
Advertisement
Answer
No, sorry. The logging format in Paketo Buildpacks, and the helpers (technical name is exec.d processes) that get installed, are not configurable at this time.
There is some work that has been done in libcnb which is the upstream library that the Java-related buildpacks use that would allow customized loggers. In theory, it should be possible to allow changing to a JSON-based logging format. That would require the v2.0 of the library which has yet to be released.
I suggest adding this as a suggestion for the 2023 Roadmap. There’s presently a discussion going on where the project is soliciting new features. You can also open an issue under the Java buildpack for tracking.