共计 3505 个字符,预计需要花费 9 分钟才能阅读完成。
默认情况下 tomcat6.0.26 日志存放路径为 tomcat6.0.26/logs 下:
[root@modelC65 tomcat6.0.26]# cd logs/
[root@modelC65 logs]# ll
total 0
-rw-r–r–. 1 root root 0 Jul 10 10:35 catalina.2016-07-10.log
-rw-r–r–. 1 root root 0 Jul 10 10:35 catalina.out
-rw-r–r–. 1 root root 0 Jul 10 10:35 host-manager.2016-07-10.log
-rw-r–r–. 1 root root 0 Jul 10 10:35 localhost.2016-07-10.log
-rw-r–r–. 1 root root 0 Jul 10 10:35 manager.2016-07-10.log
[root@modelC65 logs]# pwd
/application/app_1/tomcat6.0.26/logs
[root@modelC65 logs]#
日志配置文件为:logging.properties
即:
[root@modelC65 conf]# ll
total 92
drwxr-xr-x. 3 root root 4096 Apr 15 2015 Catalina
-rw-r–r–. 1 root root 8945 Feb 10 2015 catalina.policy
-rw-r–r–. 1 root root 3713 Feb 10 2015 catalina.properties
-rw-r–r–. 1 root root 1395 Feb 10 2015 context.xml
-rw-r–r–. 1 root root 3257 Feb 10 2015 logging.properties
-rw-r–r–. 1 root root 6843 Jul 10 10:32 server.xml
-rw-r–r–. 1 root root 1521 Feb 10 2015 tomcat-users.xml
-rw-r–r–. 1 root root 50875 Feb 10 2015 web.xml
[root@modelC65 conf]#
具体为:
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.
修改指定的路径如下:
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = /opt/app_1/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = /opt/app_1/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = /opt/app_1/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = /opt/app_1/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.
其中 catalina.out 日志文件定义路径又存在于 tomcat/bin/catalina.sh 中,即:
CATALINA_OUT (Optional) Full path to a file where stdout and stderr
will be redirected.
Default is $CATALINA_BASE/logs/catalina.out
所以在文件 catalina.sh 中可以重新定义 catalina.out 存放路径,比如:
CATALINA.OUT=/opt/app_1/logs/catlina.out
另外对于访问日志 access.log 定义可以在 conf/server.xml 中定义
<Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”logs”
prefix=”app_1_access.” suffix=”.log” pattern=”%{X-Real-IP}i %m %H %h%{Request_uri}i %q” resolveHosts=”false”/>
修改 directory=”logs” 为 directory=”/opt/app_1/logs”
更多 Tomcat 相关教程见以下内容:
CentOS 6.6 下安装配置 Tomcat 环境 http://www.linuxidc.com/Linux/2015-08/122234.htm
RedHat Linux 5.5 安装 JDK+Tomcat 并部署 Java 项目 http://www.linuxidc.com/Linux/2015-02/113528.htm
Tomcat 权威指南(第二版)(中英高清 PDF 版 + 带书签) http://www.linuxidc.com/Linux/2015-02/113062.htm
Tomcat 安全配置与性能优化 http://www.linuxidc.com/Linux/2015-02/113060.htm
Linux 下使用 Xshell 查看 Tomcat 实时日志中文乱码解决方案 http://www.linuxidc.com/Linux/2015-01/112395.htm
CentOS 64-bit 下安装 JDK 和 Tomcat 并设置 Tomcat 开机启动操作步骤 http://www.linuxidc.com/Linux/2015-01/111485.htm
CentOS 6.5 下安装 Tomcat http://www.linuxidc.com/Linux/2015-01/111415.htm
Tomcat 的详细介绍:请点这里
Tomcat 的下载地址:请点这里
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-07/133690.htm