corretto/corretto-8-docker

How could I print the Chinese correctly?

ouyunwen opened this issue · 3 comments

I print some chinese words into the file using log4j2. When I want to see the content of file by using "tail" ,I found that all of the chinese words in the file are “???”.

@ouyunwen The default encoding of character set in Log4j2 is utf8, which covers Chinese characters. (See Log4j2 layout). To root cause your issue, can you check the encoding in log4j configuration and the actual content of your log file?

Another possibility might be tail modifying the charset of the terminal. See post.

Let me know if this works for you.

@ouyunwen The default encoding of character set in Log4j2 is utf8, which covers Chinese characters. (See Log4j2 layout). To root cause your issue, can you check the encoding in log4j configuration and the actual content of your log file?

Another possibility might be tail modifying the charset of the terminal. See post.

Let me know if this works for you.

thanks.

I solved the problem by creating a new custom docker image afterwards.
I created a new docker file base on centos,and added chinese component,and change the timezone to Shanghai.
The whole content of the docker file as follows:

FROM centos:latest
#作者信息
MAINTAINER ouyunwen ouyunwen@126.com
#添加海康设备的sdk环境变量
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/data/hksdk:/data/hksdk/HCNetSDKCom"
#临时设置http代理,构建时用到,因为服务器不能访问外网
ARG http_proxy="192.168.201.227:808"
ARG https_proxy="192.168.201.227:808"
#复制入口运行文件
COPY main.sh /entrypoint/main.sh
RUN chmod +x /entrypoint/main.sh
#安装中文语言组件
RUN yum -y install kde-l10n-Chinese && yum -y reinstall glibc-common
RUN localedef -c -f UTF-8 -i zh_CN zh_CN.utf8
ENV LC_ALL "zh_CN.UTF-8"
#设置为上海时区
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
#安装corretto jdk
WORKDIR /appinstaller
COPY corretto8u222.rpm /appinstaller/corretto8u222.rpm
RUN yum -y localinstall corretto8u222.rpm
RUN rm -rf corretto8u222.rpm
WORKDIR /data
#EXPOSE 8081
#ENTRYPOINT ["sh","/entrypoint/main.sh"]

I ran into the same issue. The strange thing is that e.g. OpenJDK sets default encoding to UTF-8 in their images (https://github.com/docker-library/openjdk/blob/master/8/jdk/Dockerfile#L21). The result was that I had an app that was running perfectly fine on OpenJDK but failing on Corretto.