开发者社区> 天飞> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

统一tomcat的程序包路径,日志路径,自定义变量,JAVA启动项的配置文件示例

简介: 统一tomcat的程序包路径,日志路径,自定义变量,JAVA启动项的配置文件示例
+关注继续查看

在企业环境中,将tomcat里的日志和程序包统一到不同的路径,

自定义全局变量,自定义JAVA_OPTS都是很常见的操作。

现将相关文件作一示例,

以后可照猫画虎了。

(有时,tomcat日志的时间不对,系统的时间是对的,这里就要用GMT+8参数)



bin/setenv.sh



CLASSPATH=$CLASSPATH:/xxx/webconfigs
LOG_DIR="/xxx/weblogs/${MY_POD_NAMESPACE}_${MY_POD_NAME}"
JAVA_OPTS="$JAVA_OPTS -Duser.timezone=GMT+08"
JAVA_OPTS="$JAVA_OPTS -Dlog.home=${LOG_DIR}"
JAVA_OPTS="$JAVA_OPTS -Dxxx.log=${LOG_DIR}"
JAVA_OPTS="$JAVA_OPTS -Xms4096m -Xmx6144m -XX:MaxNewSize=512m -XX:MaxPermSize=512m"
JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=85 -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps"
JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${LOG_DIR}  -verbose:gc -Xloggc:${LOG_DIR}/gc.log"



conf/server.xml



<Server port="59076" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.core.AprLifecycleListener" />
    <!--Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" /-->
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
    <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>

    <GlobalNamingResources>
    <!-- Used by Manager webapp -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved"
           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1" maxThreads="150" minSpareThreads="25"
               enableLookups="false" redirectPort="8443" acceptCount="200"
               connectionTimeout="40000" 
               disableUploadTimeout="false"/>

    <!-- This is here for compatibility only, not required -->
    <!-- <Connector port="59009" protocol="AJP/1.3" /> -->

    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase" />
      <Host name="localhost" appBase="/xxx/webapps" unpackWARs="true">
           <Valve className="org.apache.catalina.valves.AccessLogValve" rotatable="true"
                            directory="${xxx.log}"  prefix="localhost_access.log"
                            pattern="%h %{X-FORWARDED-FOR}i %l %u %t %r %s %b  %q %{User-Agent}i %T %D" resolveHosts="false"/>
      </Host>
    </Engine>
 </Service>
</Server>


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 = ${xxx.log}
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.

2localhost.org.apache.juli.AsyncFileHandler.level = FINE
2localhost.org.apache.juli.AsyncFileHandler.directory = ${xxx.log}
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.

3manager.org.apache.juli.AsyncFileHandler.level = FINE
3manager.org.apache.juli.AsyncFileHandler.directory = ${xxx.log}
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.

4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
4host-manager.org.apache.juli.AsyncFileHandler.directory = ${xxx.log}
4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.

java.util.logging.ConsoleHandler.level = FINE
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 = 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


版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
Tomcat 部署分类|学习笔记
快速学习 Tomcat 部署分类
0 0
tomcat部署测试应用及tomcat常用组件配置记录
tomcat部署测试应用及tomcat常用组件配置记录
2205 0
企业级Tomcat部署实践及安全调优
Tomcat是Apache软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache、Sun和其他一些公司及个人共同开发而成。
1616 0
+关注
天飞
一个运维老同志
文章
问答
文章排行榜
最热
最新
相关电子书
更多
CentOS Nginx PHP JAVA多语言镜像使用手册
立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手
立即下载
JAVA反射原理以及一些常见的应用
立即下载