首页 > 其他分享 >tomcat打印日志乱码问题

tomcat打印日志乱码问题

时间:2022-12-11 21:34:15浏览次数:56  
标签:catalina tomcat juli 乱码 manager apache org 日志 AsyncFileHandler

对于 tomcat 打印中文乱码问题,处理方式如下:

找到 tomcat 安装目录下的 conf 目录,在里面找到 logging.properties 文件
修改 logging.properties 文件中设置的编码格式,主要是将 java.util.logging.ConsoleHandler.encoding = UTF-8,改为 GBK,然后重启 tomcat
如下为 tomcat 9 ,修改后的 logging.properties 文件,可直接复制使用

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

.handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

1catalina.org.apache.juli.AsyncFileHandler.level = FINE
1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
1catalina.org.apache.juli.AsyncFileHandler.maxDays = 90
1catalina.org.apache.juli.AsyncFileHandler.encoding = UTF-8

2localhost.org.apache.juli.AsyncFileHandler.level = FINE
2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
2localhost.org.apache.juli.AsyncFileHandler.maxDays = 90
2localhost.org.apache.juli.AsyncFileHandler.encoding = UTF-8

3manager.org.apache.juli.AsyncFileHandler.level = FINE
3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
3manager.org.apache.juli.AsyncFileHandler.maxDays = 90
3manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8

4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
4host-manager.org.apache.juli.AsyncFileHandler.maxDays = 90
4host-manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
java.util.logging.ConsoleHandler.encoding = GBK


############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.AsyncFileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.AsyncFileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.AsyncFileHandler

# For example, set the org.apache.catalina.util.LifecycleBase logger to log
# each component that extends LifecycleBase changing state:
#org.apache.catalina.util.LifecycleBase.level = FINE

# To see debug messages in TldLocationsCache, uncomment the following line:
#org.apache.jasper.compiler.TldLocationsCache.level = FINE

# To see debug messages for HTTP/2 handling, uncomment the following line:
#org.apache.coyote.http2.level = FINE

# To see debug messages for WebSocket handling, uncomment the following line:
#org.apache.tomcat.websocket.level = FINE

标签:catalina,tomcat,juli,乱码,manager,apache,org,日志,AsyncFileHandler
From: https://www.cnblogs.com/lhongsen/p/16974542.html

相关文章

  • ELK+FileBeat日志分析系统
    一、ELK日志分析系统概述1.1ELK简介ELK是三个开源软件的缩写,分别表示:Elasticsearch,Logstash,Kibana,它们都是开源软件。新增了一个FileBeat,它是一个轻量级的日志......
  • 分布式收集日志
    基于logstashfilter功能将nginx默认的访问日志及errorlog转换为json格式并写入elasticsearch安装nginxtarxfnginx-1.22.1.tar.gzcdnginx-1.22.1/./configure--pre......
  • java gc日志的基本知识
    回顾一下gc日志的基本知识,下面是一条gc日志:33.125:[GC[DefNew:3324k->152k(3712k),0.0025925secs]3324k>152k(11904k),0.0031680secs]从左至右,各个信息的意思为:33.1......
  • 在爬虫过程中出现乱码,那么如何处理?
    在爬虫中很容易出现乱码现象,那么具体如何处理呢?以下有几种方式,记录下。方式一:给响应对象添加encoding response=request.get(url=url,headers=headers)response.en......
  • 解决SpringCloudConfig中文乱码问题
    问题来自于配置服务端使用的编码格式为ISO-8859-1导致  这里处理后的结果添加两个类CustomizedOriginTrackedPropertiesLoader和CustomizedPropertiesPropertySource......
  • MySQL 5.7中文乱码与远程链接问题
    1.MySQL5.7中文乱码当我们直接在数据库里面输入中文时,保存后出现:Incorrectstringvalue:‘\xE9.....’forcolumn''atrow1出现上面的原因是因为字符编码设置有......
  • ELK日志分析系统
    一、ELK概述1、ELK概述ELK是三个开源项目的首字母缩写,分别是:Elasticsearch、Logstash和KibanaElasticsearch简称ES,它是一个实时的分布式搜索和分析引擎,它可以用于全文搜索,结......
  • MySQL 5.7中文乱码与远程链接问题
    (MySQL5.7中文乱码与远程链接问题)1.MySQL5.7中文乱码当我们直接在数据库里面输入中文时,保存后出现:Incorrectstringvalue:‘\xE9.....’forcolumn''atrow1出......
  • 计划管理,系统管理及日志
    一、引导过程1、开机自检服务器主机开机以后,将根据主板BIOS中的设置对CPU、内存、显卡、键盘等设备进行初步检测,检测成功后根据预设的启动顺序移交系统控制权,大多时......
  • Tomcat使用介绍
    一、tomcat介绍Tomcat服务器是一个免费的开放源代码的轻量级Web应用服务器,如apache处理静态HTML能力突出不同,tomcat处理动态HTML能力相当强大,因此一般项目都是部署apache......