zoukankan      html  css  js  c++  java
  • tomcat默认日志路径更改

    在项目访问量不断增加时,tomcat下logs也迅速增大,有时甚至因为填满了所在分区而出现无空间写入日志而导致程序出问题。 

    这时要更改logs的默认目录,指向更大的磁盘。修改主要有两步: 

    1. 修改tomcat/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.
    
    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 = /data/logs/tomcat8log/logs
    1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
    
    2localhost.org.apache.juli.AsyncFileHandler.level = FINE
    2localhost.org.apache.juli.AsyncFileHandler.directory = /data/logs/tomcat8log/logs
    2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
    
    3manager.org.apache.juli.AsyncFileHandler.level = FINE
    3manager.org.apache.juli.AsyncFileHandler.directory = /data/logs/tomcat8log/logs
    3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
    
    4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
    4host-manager.org.apache.juli.AsyncFileHandler.directory = /data/logs/tomcat8log/logs
    4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
    
    java.util.logging.ConsoleHandler.level = FINE
    java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter


    把其中各个directory路径更改为要存储对应日志的路径,一般都是设置为同一个地方。 

    2. 修改tomcat/bin/catalina.sh 

    if [ -z "$CATALINA_OUT" ] ; then
      CATALINA_OUT=/data/logs/tomcat8log/logs/catalina.out
    fi
    

    把CATALINA_OUT修改为与logging.properties修改一样的路径,便于日志集中管理。 

    重启tomcat就能看到diska/tomcatlog/logs/下开始产生新日志了。 

    拼一个春夏秋冬.赢一个无悔人事。
  • 相关阅读:
    在页面中控制媒体流的起播点和播放长度
    缓冲区数据转换为字符串输出
    编程中注意的一个问题
    一个整合SQL语句的类
    注意服务器系统日期对防病毒软件的影响
    网络病毒源的排查(2005年3月22日维护记录)
    升级到 Microsoft .NET >Visual Basic 6.0 控件和 .NET 控件的区别
    修改您的站点设计以改善下载体验
    下一版本Windows® CE 开发工具Smart Device Extensions for Microsoft Visual Studio® .NET
    WINDOWS (服务器) 和 DOS(客户端) 网络互连 基于TCP/IP的编程实现
  • 原文地址:https://www.cnblogs.com/wylb/p/7783171.html
Copyright © 2011-2022 走看看