Tomcat 5.5 has done away with localhost_log
which you may be familiar with as the runtime exception/stack trace log. These types of error are usually thrown by uncaught exceptions, but are still valuable to the developer. They can now be found in the stdout
log.
If you need to setup cross-context detailed logging from within Tomcat's code, then you can use a simple log4j configuration. Note that this logging van be very verbose depending on the log level you chose to use. Note also that a log4j logging configuration is not going to produce stack trace type logging: those stack traces are output to stdout
as discussed above.
Follow the following steps to setup a file named tomcat.log that has internal Tomcat logging output to it:
- Create a file called log4j.properties with the following content and save it into common/classes.
|
|
|
|
log4j.rootLogger=DEBUG, R log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=${catalina.home}/logs/tomcat.log log4j.appender.R.MaxFileSize=10MB log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
|
|
|
|
|
-
Download Log4J (v1.2 or later) and place the log4j jar in $CATALINA_HOME/common/lib.
-
Download Commons Logging and place the commons-logging.jar (not commons-logging-api.jar) in $CATALINA_HOME/common/lib with the log4j jar.
- Start Tomcat
This log4j configuration sets up a file called tomcat.log in your Tomcat logs folder with a maximum file size of 10MB and up to 10 backups. DEBUG level is specified which will result in the most verbose output from Tomcat.
You can (and should) be more picky about which packages to include in the logging. Tomcat 5.5 uses defines loggers by Engine and Host names. For example, for a default Catalina localhost log, add this to the end of the log4j.properties above. Note that there are known issues with using this naming convention (with square brackets) in log4j XML based configuration files, so we recommend you use a properties file as described until a future version of log4j allows this convention.
- log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=DEBUG, R
- log4j.logger.org.apache.catalina.core=DEBUG, R
- log4j.logger.org.apache.catalina.session=DEBUG, R
Be warned a level of DEBUG will produce megabytes of logging and slow startup of Tomcat. This level should be used sparingly when debugging of internal Tomcat operations is required.
Your web applications should certainly use their own log4j configuration. This is valid with the above configuration. You would place a similar log4j.properties file in your web application's WEB-INF/classes folder, and log4j1.2.8.jar into WEB-INF/lib. Then specify your package level logging. This is a basic setup of log4j which does *not* require Commons-Logging, and you should consult the log4j documentation for more options. This page is intended only as a bootstrapping guide.
分享到:
相关推荐
tomcat默认使用Java.util.logging记录日志,默认只记录tomcat的日志,不记录应用的日志。tomcat支持采用log4j进行日志记录,配置方法如下: 1.更新最新的tomcat_juli.jar包到./bin/目录下; 2.拷贝log4j.jar,lo4j....
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory ``` 这个错误通常是因为Tomcat启动时找不到必要的类库。解决方法如下: 1. **确认JDK环境**: 确保正确设置了...
HOME -Djava.io.tmpdir=$TOMCAT_HOME/temp -Djava.util.logging.config.file=$TOMCAT_HOME/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina....
提供的文档资料如《ApacheTomcat整合教程.pdf》和《BOXIN网站系统环境搭建APACHE+TOMCAT.pdf》将更深入地指导你完成具体步骤。在学习过程中,遇到问题可参考官方文档或社区资源,不断积累经验,提高技术水平。
Tomcat的日志配置可以通过编辑`conf/logging.properties`文件来实现。以下是一些关键配置示例: 1. **catalina.日期.log、localhost.日期.log** 日志配置: - 日志级别:`catalina.org.apache.juli.FileHandler....
Configure logging for web applications deployed on Tomcat server Who this book is for This book is for those Web developers and/or Java programmers new to the open-source Apache Tomcat Web server. ...
本文主要介绍的是Linux下重新启动Tomcat的步骤,在Linux系统下,重启Tomcat使用命令操作的! 具体的步骤如下: ... 00:30:13 /usr/local/java/bin/java -Djava.util.logging.config.file=/usr/local/tomcat
在Linux系统下,重启Tomcat使用命令操作的! 首先,进入Tomcat下的bin目录 cd /usr/local/tomcat/bin 使用Tomcat关闭命令 ... 00:00:04 /opt/jdk1.6.0_37/bin/java -Djava.util.logging.config.file=/opt/t
1. 修改catalina.sh 进入tomcat安装目录/bin,找到catalina.sh,并下载到本地,同时进行备份。 对本地的catalina.sh进行修改,将下图红框所示地方改...进入tomcat安装目录/conf/,找到logging.properties,并下载到本
Tomcat默认的日志是用java.util.logging,有几点不足,文件catalian.out不能像log4j一样按天生成,将越来越大。日志格式和项目中用log4j打出来的不一致,不利于解析。 从tomcat官网...
1、修改catalina.sh 进入tomcat安装目录/bin,找到...进入tomcat安装目录/conf/,找到logging.properties,先进行备份。 对本地的logging.properties进行修改,将所有的${catalina.base}/logs全部修改为/data/logs 3
通常,在Tomcat的安装目录下的logs文件夹中,可以通过查看当天日期的日志文件,找到类似 Address already in use: bind 这样的错误信息,从而确定问题所在。一旦确定是哪个进程占用端口,可以通过任务管理器查找并...
│ │ logging.properties │ │ server.xml │ │ server.xml.bak │ │ tomcat-users.xml │ │ web.xml │ │ │ └─Catalina │ └─localhost ├─jdk1.7.0_21 │ │ COPYRIGHT │ │ LICENSE │ │ README....
一般在部署Tomcat后,运行久了,catalina.out文件会越来越大,对系统的稳定造成了一定的影响。 1、可通过修改conf/logging.properties日志配置文件来屏蔽掉这部分的日志信息。 [root@localhost conf]# pwd /usr/...
- WebLogic服务器默认提供了Commons Logging类包,这与其他服务器(如Tomcat)有所不同。 - 在WebLogic中使用Log4j需要对Commons Logging进行特定配置,以确保与Log4j兼容。 2. **Commons Logging配置** - **...
9. **JARs in lib directory**:Tomcat的lib目录通常包含必要的库文件,如JDBC驱动,以便Tomcat可以连接到数据库。 备份“conf.tar.gz”可能是为了在更新、升级或出现问题时恢复原有的配置,确保Tomcat的稳定运行。...
If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers, the corresponding directory should be used. For more information, see: ...
-- To use the plugin goals in your POM or parent POM --> <groupId>org.apache.maven.plugins <artifactId>maven-surefire-report-plugin <version>2.14.1 <groupId>org.apache.maven.plugins ...
本项目“简单易用的日志系统”是基于Tomcat服务器和SLF4J(Simple Logging Facade for Java)实现的,旨在为团队提供一个便捷的日志查看解决方案。 首先,让我们深入了解SLF4J。SLF4J是一个为各种日志框架提供一个...