1、部署war包的默認(rèn)位置
在conf/server.xml中修改docBase目錄
<Host ...>
<Context path="" reloadable="true" docBase="/apps/deploy/ossadmin/oss.war" />
<Valve .../>
</Host>
2、存放日志的默認(rèn)位置
2.1 accessLog日志
同樣也是在conf/server.xml中修改Host節(jié)點(diǎn)
<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/目錄下創(chuàng)建setenv.sh文件并定義CATALINA_OUT變量即可
setenv.sh:
...
CATALINA_OUT=/apps/logs/myapp/catalina.out
2.2 其他日志
編輯conf/logging.property中xxx.directory的值為目標(biāo)目錄即可
# 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"