Tomcat默认日志路径更改

在项目访问量不断增加时,tomcat下logs也迅速增大,有时甚至因为填满了所在分区而出现无空间写入日志而导致程序出问题。

这时要更改logs的默认目录,指向更大的磁盘。修改主要有两步:

1. 修改tomcat/conf下的logging.properties

############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
 
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = /diska/tomcatlog/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
 
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = /diska/tomcatlog/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
 
3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = /diska/tomcatlog/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
 
4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = /diska/tomcatlog/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.
 
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
 
 
############################################################

把其中各个directory路径更改为要存储对应日志的路径,一般都是设置为同一个地方。

2. 修改tomcat/bin/catalina.sh

if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT=/diska/tomcatlog/logs/catalina.out

把CATALINA_OUT修改为与logging.properties修改一样的路径,便于日志集中管理。

重启tomcat就能看到diska/tomcatlog/logs/下开始产生新日志了。

还没有评论,快来抢沙发!

发表评论

  • 😉
  • 😐
  • 😡
  • 😈
  • 🙂
  • 😯
  • 🙁
  • 🙄
  • 😛
  • 😳
  • 😮
  • emoji-mrgree
  • 😆
  • 💡
  • 😀
  • 👿
  • 😥
  • 😎
  • ➡
  • 😕
  • ❓
  • ❗
  • 66 queries in 0.386 seconds