统一tomcat的程序包路径,日志路径,自定义变量,JAVA启动项的配置文件示例-阿里云开发者社区

开发者社区> 天飞> 正文

统一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


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

相关文章
Java之 将程序打包成jar包
准备材料:   1.java文件:        Helloworld.java   package com.ray; public class HelloWorld{ public static void main(String[] args) { System.out.println("Hello!jar"); } }      2.指定目录:建一个目录,来存放.class文件和.jar文件。
629 0
【项目启动】 tomcat启动,项目无法启动,无法正常访问/项目可以启动,报错:java.lang.ClassNotFoundException: ContextLoaderListener
使用maven搭建项目(这个错误和是不是使用maven搭建项目没有关系),然后部署到tomcat中运行。   出现问题1: tomcat跑起来了,但是启动时间很短,没有报错,项目不能正常访问 项目启动时间很短,并且没有报错 并且项目无法正常访问   发现问题过程: 查看tomcat下,发现这个项目在tomcat的webapps下部署的仅仅是项目的部分文件,有好多的东西并没有部署进来 我们发现tomcat下部署的本项目中 并没有lib依赖包库 等目录。
1799 0
SCSS 文件里的感叹号用法 - 给变量设置默认值
SCSS 文件里的感叹号用法 - 给变量设置默认值
8 0
log4j配置单独日志文件输出
log4j.logger.batteryHistory=ERROR,BD log4j.appender.BD=org.apache.log4j.FileAppender log4j.appender.
870 0
nginx日志格式及自定义日志配置
nginx的log日志分为access log 和 error log 其中access log 记录了哪些用户,哪些页面以及用户浏览器、ip和其他的访问信息 error log 则是记录服务器错误日志 错误日志的形式如下: 10.
805 0
运维调试记录:Ubuntu下通过PPA方式安装Java 8并自动配置环境变量
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhaobryant/article/details/51125246 Install OpenJDK 8 in Ubuntu: For 14.
810 0
+关注
天飞
一个运维老同志
1512
文章
0
问答
文章排行榜
最热
最新
相关电子书
更多
《2021云上架构与运维峰会演讲合集》
立即下载
《零基础CSS入门教程》
立即下载
《零基础HTML入门教程》
立即下载