导读
由于项目需要,云空间的tomcat默认输入log日志越来越大,加上该挂载的磁盘容量较小。So,这里面从新挂载了一个新的磁盘,然后将tomcat启动日志等信息存储到该空间的某个目录下。
步骤
目的,将/data/tomcat.8.0/logs
文件夹下的日志,改成输出在/info/logs
目录下。
修改catalina.sh文件
修改tomcat中bin目录下的catalina.sh文件(这里可以直接在线使用vi命令编辑,也可以下载编辑后重新上传):
原有:
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out
fi
改为info/logs目录下
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT=/info/logs/catalina.%Y-%m-%d.out
fi
修改logging.properties
修改一下四个文件路径。
- 原有: ```powershell
#
Handler specific properties.
Describes specific configuration info for Handlers.
#
1catalina.org.apache.juli.AsyncFileHandler.level = FINE 1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs 1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
2localhost.org.apache.juli.AsyncFileHandler.level = FINE 2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs 2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
3manager.org.apache.juli.AsyncFileHandler.level = FINE 3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs 3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
4host-manager.org.apache.juli.AsyncFileHandler.level = FINE 4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/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
#
- 改为:
```powershell
############################################################
1catalina.org.apache.juli.AsyncFileHandler.level = FINE
1catalina.org.apache.juli.AsyncFileHandler.directory = /info/logs
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
2localhost.org.apache.juli.AsyncFileHandler.level = FINE
2localhost.org.apache.juli.AsyncFileHandler.directory = /info/logs
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
3manager.org.apache.juli.AsyncFileHandler.level = FINE
3manager.org.apache.juli.AsyncFileHandler.directory = /info/logs
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
4host-manager.org.apache.juli.AsyncFileHandler.directory = /info/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
############################################################
重启Tomcat
前面的两个文件修改后,然后重启Tomcat即可。在对应的info/logs目录下,可以找到对应的日志信息,并且查看到新的日志输出在该目录下,表示修改成功。