Solve the problem of garbled log4j on Linux

Source: Internet
Author: User

http://blog.csdn.net/lzc3144/article/details/7643210


Use log4j, when the win system in the normal display of Chinese, but published to the Linux system when Chinese will appear garbled

Because the encoding format (encoding) is not set in the log4j configuration file, Log4j uses the system default encoding. Lead to garbled characters.

The solution is to set the encoding format UTF-8 (sometimes changed to UTF-8 or garbled, need to be set to GBK, which may be related to the encoding of the character you entered):

Log4j.appender.logfile.encoding=utf-8

# # # File Log #####

Log4j.appender.logfile=org.apache.log4j.rollingfileappender

Log4j.appender.logfile.file=d:/log/shop/logs.log

Log4j.appender.logfile.maxfilesize=5mb

Log4j.appender.logfile.threshold=debug

Log4j.appender.logfile.layout=org.apache.log4j.patternlayout

LOG4J.APPENDER.LOGFILE.LAYOUT.CONVERSIONPATTERN=[%D{MM/DDHH:MM:SS,SSS}] [%-3p]%c{1}:%m%n

Log4j.appender.logfile.encoding=utf-8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.