


How to solve the Chinese garbled characters in Tomcat logs?
The Chinese language of the Linux system is garbled, which is a problem that many friends often encounter when they first come into contact with Linux. Moreover, when we move the projects that have been deployed in Wndows to run on Linux, the Chinese output logs of Tomcat are all garbled. (Normal on Windows), it looks very frustrating, so how should we solve it?
System Chinese garbled code
- CentOS 7.0 64-bit ##jdk-8u11-linux-x64.
- ##apache-tomcat-8.5. 16
## Solution steps:
1. Install the Chinese language pack
First check whether the Chinese language pack is installed on the system
locale -a (list the names of all available public locale environments)
machines in her in in in on in on in on in on in on in on the names in all available public locales What do several items mean?
{Language code}_{Country code}.{Character set}
zh is the code for Chinese, CN is the code for China, gb18030, gb2312, utf8 is the language character set
yum install kde-l10n-Chinese somehow 11M in about 11M
# Before modifying the configuration file, let’s take a look at the current system locale
("en_US.UTF-8" can be understood as "you speak English, you are in the United States, and the language character set is UTF-8" according to the above content)
Each item The meanings are:
LANG: The language of the current system LC_CTYPE: Language symbols and their classification
LC_NUMERIC: Numbers LC_COLLATE: Comparison and sorting Habit
LC_TIME: Time display format
Add the following two lines of code LANG="zh_CN.UTF-8"
LC_ALL="zh_CN.UTF-8"
# source /etc/sysconfig/i18n Modify the locale.cnf configuration file
# vim /etc/locale.conf
LANG="zh_CN.UTF-8"
## shall should should should be 10-100ml
##
####
#### Properties->Terminal (the terminal connection tool I use is Xshell. For other connection tools, please change the encoding method on Baidu)
Change the encoding to UTF-8
Reconnect and check the current system locale
Locale
It is found that the system locale has been successfully changed to "zh_CN.UTF-8"
Try editing Chinese again
# SUCCESS! At this point, the problem of garbled Chinese characters in the system has been solved. 4. Solve the problem of garbled Chinese characters in the Tomcat output log
Now that the Chinese garbled characters in the system have been solved, will the Chinese garbled characters in the Tomcat output log also be solved?
Let’s take a look at the Tomcat output log now
Enter the Tomcat directory
#, Tomcat log Chinese is still garbled.
Analysis: Since Chinese garbled characters no longer appear in the system, it proves that the system language environment is normal, but Chinese garbled characters still appear in the Tomcat log, indicating that it is an internal problem of Tomcat. I checked some information online and found that it is the JVM. (Java Virtual Machine)
The character set used by the Java virtual machine is inconsistent with the character set used by the system. If you know the reason, the problem will be solved. You can modify the JVM startup parameters by configuring the JVM startup parameters. Character set purpose.
# ls -l ./bin/
Find daemon.sh and catalina.sh and add the following codes respectively:
JAVA_OPTS= "$JAVA_OPTS -Djavax.servlet.request.encoding=UTF-8 -Dfile.encoding=UTF-8 -Duser.language=zh_CN -Dsun.jnu.encoding=UTF-8"
# vim ./ bin/daemon.sh
# vim ./bin/catalina.sh
Save and exit, restart Tomcat # ./bin/shutdown.sh
# ./bin/startup.sh
Now check the output log
# tail -f ./ logs/catalina.out
The above is the detailed content of How to solve the Chinese garbled characters in Tomcat logs?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

When loading CentOS-7.0-1406, there are many optional versions. For ordinary users, they don’t know which one to choose. Here is a brief introduction: (1) CentOS-xxxx-LiveCD.ios and CentOS-xxxx- What is the difference between bin-DVD.iso? The former only has 700M, and the latter has 3.8G. The difference is not only in size, but the more essential difference is that CentOS-xxxx-LiveCD.ios can only be loaded into the memory and run, and cannot be installed. Only CentOS-xxx-bin-DVD1.iso can be installed on the hard disk. (2) CentOS-xxx-bin-DVD1.iso, Ce

The Linux Chinese garbled problem is a common problem when using Chinese character sets and encodings. Garbled characters may be caused by incorrect file encoding settings, system locale not being installed or set, and terminal display configuration errors, etc. This article will introduce several common workarounds and provide specific code examples. 1. Check the file encoding setting. Use the file command to view the file encoding. Use the file command in the terminal to view the encoding of the file: file-ifilename. If there is "charset" in the output

It's no secret that the iPhone is one of the most user-friendly electronic gadgets, and one of the reasons why is that it can be easily personalized to your liking. In Personalization, you can change the language to a different language than the one you selected when setting up your iPhone. If you're familiar with multiple languages, or your iPhone's language setting is wrong, you can change it as we explain below. How to Change the Language of iPhone [3 Methods] iOS allows users to freely switch the preferred language on iPhone to adapt to different needs. You can change the language of interaction with Siri to facilitate communication with the voice assistant. At the same time, when using the local keyboard, you can easily switch between multiple languages to improve input efficiency.

In the Windows 10 system, garbled characters are common. The reason behind this is often that the operating system does not provide default support for some character sets, or there is an error in the set character set options. In order to prescribe the right medicine, we will analyze the actual operating procedures in detail below. How to solve Windows 10 garbled code 1. Open settings and find "Time and Language" 2. Then find "Language" 3. Find "Manage Language Settings" 4. Click "Change System Regional Settings" here 5. Check the box as shown and click Just make sure.

Open the centos7 page and appear: welcome to emergency mode! afterloggingin, type "journalctl -xb" to viewsystemlogs, "systemctlreboot" toreboot, "systemctldefault" to tryagaintobootintodefaultmode. giverootpasswordformaintenance(??Control-D???): Solution: execute r

Many users found that their personal software was garbled after upgrading the win11 system. So how to solve this problem? Now let the editor carefully introduce to users the analysis of garbled code problems in some software in win11. Analysis of garbled characters in some software in win11 1. Click the search box in the taskbar in the lower left corner and enter control panel to open it. 3. Click on the area. 5. Then uncheck the small box for beta version in the window, and finally restart the computer to solve the problem.

Title: Methods and code examples to solve the problem of garbled characters when importing Chinese data into Oracle. When importing Chinese data into Oracle database, garbled characters often appear. This may be due to incorrect database character set settings or encoding conversion problems during the import process. . In order to solve this problem, we can take some methods to ensure that the imported Chinese data can be displayed correctly. The following are some solutions and specific code examples: 1. Check the database character set settings In the Oracle database, the character set settings are

Tips for dealing with garbled Chinese file names in PHP During the development process, we often encounter the problem of garbled Chinese file names, especially when processing files uploaded by users. In PHP, how to correctly handle garbled file names is a common and important problem. This article will introduce some techniques for dealing with garbled Chinese file names and provide specific code examples to help readers better deal with this challenge. Problem description: When users upload files, the Chinese file names sometimes appear to be garbled. This is because different operating systems and browsers
