二丫讲梵 二丫讲梵
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)

二丫讲梵

行者常至,为者常成
首页
  • 最佳实践
  • 迎刃而解
  • Nginx
  • Php
  • Zabbix
  • AWS
  • Prometheus
  • Grafana
  • CentOS
  • Systemd
  • Docker
  • Rancher
  • Ansible
  • Ldap
  • Gitlab
  • GitHub
  • Etcd
  • Consul
  • RabbitMQ
  • Kafka
  • MySql
  • MongoDB
  • OpenVPN
  • KVM
  • VMware
  • Other
  • ELK
  • K8S
  • LLM
  • Nexus
  • Jenkins
  • 随写编年
  • 家人物语
  • 追忆青春
  • 父亲的朋友圈
  • 电影音乐
  • 效率工具
  • 博客相关
  • Shell
  • 前端实践
  • Vue学习笔记
  • Golang学习笔记
  • Golang编程技巧
  • 学习周刊
  • Obsidian插件周刊
关于
友链
  • 本站索引

    • 分类
    • 标签
    • 归档
  • 本站页面

    • 导航
    • 打赏
  • 我的工具

    • 备忘录清单 (opens new window)
    • json2go (opens new window)
    • gopher (opens new window)
    • 微信MD编辑 (opens new window)
    • 国内镜像 (opens new window)
    • 出口IP查询 (opens new window)
    • 代码高亮工具 (opens new window)
  • 外站页面

    • 开往 (opens new window)
    • ldapdoc (opens new window)
    • HowToStartOpenSource (opens new window)
    • vdoing-template (opens new window)
GitHub (opens new window)
  • 最佳实践

  • 迎刃而解

  • Nginx

  • Php

  • Zabbix

  • AWS

  • Prometheus

  • Grafana

  • Loki

  • CentOS

  • Supervisord

  • Systemd

  • Docker

  • Docker-Compose

  • Rancher

  • Ansible

  • OpenLdap

  • GitLab

  • GitHub

  • Etcd

  • Consul

  • RabbitMQ

  • Kafka

  • Mysql

  • MongoDB

  • OpenVPN

  • Kvm

  • VMware

  • 配置文件详解

  • Other

    • 整理蓝鲸社区版3-X部署文档
    • 关于开源堡垒机jumpserver_1-2的一些体验记录
    • 防火墙基础知识之SNAT详解
    • 关于easyops的社区版与正式版两者体验之思考
    • DELL R430服务器做raid以及安装操作系统过程
    • CentOS系统安装之后的优化
    • 如何快速的批量配置某台主机对多台主机免密码登陆
    • Python-2-7的安装
    • pinpoint安装流程
    • CentOS7上Python-3-6的安装
    • 记录我与maven的故事三则
    • tomcat默认日志优化处理
      • 1,针对 logging.properties。
      • 2,关闭 localhostaccesslog 日志。
      • 3,管理 catalina.out。
    • Maven 基础知识大全汇总整理
    • 会话管理工具tmux整理
    • 使用pure-ftpd搭建ftp服务
    • 简单快速部署轻量Git服务器gogs
    • 使用athens部署企业内部Gitlab包的私服代理
    • 快速部署cerebro-v0-9-4监控es集群状态
    • 使用transfer部署一个内网上传程序
    • 认识并使用一个透明代理http-server
  • 运维观止
  • Other
二丫讲梵
2018-09-12
目录

tomcat默认日志优化处理

文章发布较早,内容可能过时,阅读注意甄别。

正常情况下,tomcat 默认的程序会输出一大堆的日志,而这些日志,对日常运维来说,帮助并不大,反而徒增不少的烦人文件。

这些都可以通过配置给优化掉。

# 1,针对 logging.properties。

修改conf/logging.properties日志配置文件可以屏蔽掉部分的日志信息。

将 level 级别设置成 WARNING 就可以大量减少日志的输出,当然也可以设置成 OFF,直接禁用掉。

可以直接用下边的内容替换掉原来的文件。如果也是tomcat8的话。
1
[root@node1 tomcat]$cat conf/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.


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

1catalina.org.apache.juli.AsyncFileHandler.level = OFF
1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.

java.util.logging.ConsoleHandler.level = OFF
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter


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

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

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

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = OFF
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

image

# 2,关闭 localhost_access_log 日志。

修改在 tomcat 的安装目录 conf 文件夹下 server.xml 里配置,将 AccessLogValve 注释掉。

<!-- Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" / -->
1
2
3

一般这段代码的位置就在配置的底部,注释掉。

# 3,管理 catalina.out。

这个文件是 tomcat 的启动日志,很多时候可以帮助我们运维,可以留下来。

如果需要关闭,则可以设置bin/catalina.sh文件:

搜索:

if [ -z "$CATALINA_OUT" ] ; then
  CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
fi
1
2
3

可以更改后边的输出路径为/dev/null,让启动日志从此无影无踪。

但是一般不建议关闭这条日志输出,而时间长了之后,这个文件又会非常大,可以通过定时任务的策略进行定期清空处理:

crontab -e

#clean the log
0 */4 * * * echo a > /usr/local/tomcat/logs/catalina.out
1
2
3
4
微信 支付宝
上次更新: 2024/07/04, 22:40:37
记录我与maven的故事三则
Maven 基础知识大全汇总整理

← 记录我与maven的故事三则 Maven 基础知识大全汇总整理→

最近更新
01
学习周刊-总第212期-2025年第21周
05-22
02
从赵心童世锦赛夺冠聊聊我的斯诺克情缘
05-16
03
学习周刊-总第211期-2025年第20周
05-15
更多文章>
Theme by Vdoing | Copyright © 2017-2025 | 点击查看十年之约 | 浙ICP备18057030号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式