my project config: jdk17 springboot3.1.1
the log code:
logger.error("idm适配执行失败了", e);
build package:
mvn spring-boot:build-image -Pnative
run:
docker run --rm -p 9876:9876 auth-server:1.0-SNAPSHOT
the log output in std:
idm???????
add config:
<image>
<env>
<BPE_DELIM_JAVA_TOOL_OPTIONS xml:space="preserve"> </BPE_DELIM_JAVA_TOOL_OPTIONS>
<BPE_APPEND_JAVA_TOOL_OPTIONS>-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8</BPE_APPEND_JAVA_TOOL_OPTIONS>
<BPE_LANG>C.UTF-8</BPE_LANG>
<!-- 禁用 CPU 优化 -->
<!-- https://github.com/spring-projects/spring-boot/issues/36576 -->
<!--<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>-march=compatibility</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>-->
<BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
-H:+AddAllCharsets
-H:+IncludeAllLocales
</BP_NATIVE_IMAGE_BUILD_ARGUMENTS>
</env>
</image>
Still unable to output Chinese logs
Comment From: scottfrederick
This likely caused by the fact that the base OS used in the generated image for your application does not include the locales that are required. There is a StackOverflow question that deals with what appears to be a similar situation: https://stackoverflow.com/questions/65524052/how-can-the-locale-and-encoding-set-in-cloudfoundry-buildpack-docker-image-built/. Please try the solution suggested there.
If you have any follow-up questions, please reply to that StackOverflow question or create a new one.