1、部署war包的默认位置
在conf/server.xml
中修改docBase
目录
<Host ...>
<Context path="" reloadable="true" docBase="/apps/deploy/ossadmin/oss.war" />
<Valve .../>
</Host>
2、存放日志的默认位置
2.1 accessLog日志
同样也是在conf/server.xml
中修改Host
节点
<Host ...>
<!-- directory输入需要保存的路径 -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="/apps/logs/myapp"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
2.2 catalina.out日志
在bin/catalina.sh
中的官方注释
# Environment Variable Prerequisites
#
# Do not set the variables in this script. Instead put them into a script
# setenv.sh in CATALINA_BASE/bin to keep your customizations separate.
...
...
# CATALINA_OUT (Optional) Full path to a file where stdout and stderr
# will be redirected.
# Default is $CATALINA_BASE/logs/catalina.out
故只需在bin/目录下创建setenv.sh文件并定义CATALINA_OUT变量即可
setenv.sh:
...
CATALINA_OUT=/apps/logs/myapp/catalina.out
2.2 其他日志
编辑conf/logging.property
中xxx.directory
的值为目标目录即可
# logging.base = ${catalina.base}/logs
1catalina.org.apache.juli.AsyncFileHandler.level = FINE
1catalina.org.apache.juli.AsyncFileHandler.directory = /apps/logs/myapp
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
2localhost.org.apache.juli.AsyncFileHandler.level = FINE
2localhost.org.apache.juli.AsyncFileHandler.directory = /apps/logs/myapp
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
3manager.org.apache.juli.AsyncFileHandler.level = FINE
3manager.org.apache.juli.AsyncFileHandler.directory = /apps/logs/myapp
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
4host-manager.org.apache.juli.AsyncFileHandler.directory = /apps/logs/myapp
4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
3、tomcat日志乱码
linux中需要为tomcat指定文件编码为utf-8
在bin/catalina.sh
中的官方注释
# CATALINA_OPTS (Optional) Java runtime options used when the "start",
# "run" or "debug" command is executed.
# Include here and not in JAVA_OPTS all options, that should
# only be used by Tomcat itself, not by the stop process,
# the version command etc.
# Examples are heap size, GC logging, JMX ports etc.
同样自定义的变量放在bin/setenv.sh
中即可
bin/setenv.sh:
...
JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=utf-8"