导读


由于项目需要,云空间的tomcat默认输入log日志越来越大,加上该挂载的磁盘容量较小。So,这里面从新挂载了一个新的磁盘,然后将tomcat启动日志等信息存储到该空间的某个目录下。

步骤


目的,将/data/tomcat.8.0/logs文件夹下的日志,改成输出在/info/logs目录下。
image.png

修改catalina.sh文件

修改tomcat中bin目录下的catalina.sh文件(这里可以直接在线使用vi命令编辑,也可以下载编辑后重新上传):

  • 原有:

    1. if [ -z "$CATALINA_OUT" ] ; then
    2. CATALINA_OUT="$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out
    3. fi
  • 改为info/logs目录下

    1. if [ -z "$CATALINA_OUT" ] ; then
    2. CATALINA_OUT=/info/logs/catalina.%Y-%m-%d.out
    3. 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

#
  1. - 改为:
  2. ```powershell
  3. ############################################################
  4. 1catalina.org.apache.juli.AsyncFileHandler.level = FINE
  5. 1catalina.org.apache.juli.AsyncFileHandler.directory = /info/logs
  6. 1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
  7. 2localhost.org.apache.juli.AsyncFileHandler.level = FINE
  8. 2localhost.org.apache.juli.AsyncFileHandler.directory = /info/logs
  9. 2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
  10. 3manager.org.apache.juli.AsyncFileHandler.level = FINE
  11. 3manager.org.apache.juli.AsyncFileHandler.directory = /info/logs
  12. 3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
  13. 4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
  14. 4host-manager.org.apache.juli.AsyncFileHandler.directory = /info/logs
  15. 4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
  16. java.util.logging.ConsoleHandler.level = FINE
  17. java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
  18. ############################################################

重启Tomcat

前面的两个文件修改后,然后重启Tomcat即可。在对应的info/logs目录下,可以找到对应的日志信息,并且查看到新的日志输出在该目录下,表示修改成功。
image.png

END