`

How to rotate tomcat logs

    博客分类:
  • web
 
阅读更多

If catalina.out becomes 2GB in size, tomcat crashes and fails to start without any error message. To avoid this scenario you should rotate catalina.out frequently. This article describes how to setup auto rotation of catalina.out on a linux/unix machine.

How to automatically rotate catalina.out dail

1. Create this file

1. /etc/logrotate.d/tomcat

 2. Copy the following contents into the above file

/var/log/tomcat/catalina.out { 
copytruncate 
daily 
  dateext 
rotate 7 
compress 
missingok 
}

 

About the above configuration:

  • Make sure that the path /var/log/tomcat/catalina.out above is adjusted to point to your tomcat’s catalina.out
  • daily - rotates the catalina.out daily
  • rotate – keeps at most 7 log files
  • compress – compresses the rotated files
  • dateext : 在归档文件后,将会使用日期进行标注。如果这参数不指定的话,归档文件将会标注为数字。

You don’t need to do anything else.

How it works

  1. Every night the cron daemon runs jobs listed in the /etc/cron.daily/ directory
  2. This triggers the /etc/cron.daily/logrotate file which is generally shipped with linux installations. It runs the command “/usr/sbin/logrotate /etc/logrotate.conf
  3. The /etc/logrotate.conf includes all scripts in the /etc/logrotate.d/ directory.
  4. This triggers the /etc/logrotate.d/tomcat file that you wrote in the previous step.

Run logrotate manually

Run the following command to run the cron job manually

1. /usr/sbin/logrotate /etc/logrotate.conf

More logrotate options

To see all logrotate options on your system, see the manual:

man logrotate

你可以看到在 Tomcat 的日志目录下创建了一个文件:
-rw-rw-r-- 1 tomcat tomcat   133540 Jul 13 09:39 catalina.out-20110713
If no dateext specified, 如下面的内容:
-rw-rw-r-- 1 tomcat tomcat 33790228 Jul 13 09:33 catalina.out.1

分享到:
评论

相关推荐

    tomcat logs

    tomcat logs

    删除tomcat下logs文件的批处理工具

    删除tomcat下产生的日志文件,配合计划任务使用,会更加有效果呢.

    How to enable and view traffic logs in the J-Web_GUI on SRX devices

    How to enable and view traffic logs in the J-Web_GUI on SRX devices

    Laravel开发-laravel-logs-rotate

    Laravel开发-laravel-logs-rotate 使用压缩旋转文件日志

    Tomcat 不显示详细日志的问题

    Tomcat的详细错误日志不见了,只报一个万恶的Context [] startup failed due to previous errors,却找不到previous errors具体是啥东西

    Practical Hadoop Ecosystem(Apress,2016)

    This book is a practical guide on using...How to stream Logs to HDFS with Apache Flume How to transfer data from MySQL database to Hive, HDFS and HBase with Sqoop How create a Hive table over Apache Solr

    《Back-end Performance》2017 英文原版 PDF格式

    How to Process Server Logs by Daniel Berman This book is for all back-end developers that want to build sites and apps that are more performant. You’ll need to be familiar with server-side ...

    Tomcat日志问题

    Tomcat日志问题 使用logratate这个工具, #vi /etc/logrotate.d/.../usr/local/tomcat/logs/catalina.out { rotate 10 copytruncate nocompress notifempty missingok nomail olddir /usr/local/src/data/ size 1000 }

    apache mod_log_rotate

    此apache mod_log_rotate 是win32下vc9版的apache 日志文件管理工具。 使用: 复制mod_log_rotate.so到 ...CustomLog logs/access_log.%Y%m%d-%H%M%S common Original Home: http://www.hexten.net/mod_log_rotate/

    log4j:ERROR Failed to rename错误解决办法

    在Tomcat6下使用Log4j记录日志,天创建新日志文件时(日志文件设置为:org.apache.log4j.DailyRollingFileAppender)报: log4j:ERROR Failed to rename错误; 网上查找了下原因,大概意思是日志文件始终被占有,所以...

    Tomcat监控工具Probe,支持tomcat6-7-8-9.zip

    Logs:tomcat日志 Threads:tomcat线程,可以查看线程的状态等信息,还可以杀死线程 Cluster:tomcat集群 System Information:系统信息 Connectors:connector信息,可以看到每秒的请求数、响应时间...

    tomcat7 linux版

    tomcat7 linux版 专用 进入tomcat服务器的bin目录,然后执行"./startup.sh"命令启动...查看tomcat服务器的Log信息,看看tomcat服务器是否已经正常启动,进入tomcat服务器下的logs目录,打开catalina.out文件进行查看

    docker-centos7-tomcat8

    docker-centos7-tomcat... $ docker run -d -v / path / to / webapps:/ tomcat / webapps -v / path / to / logs /:/ tomcat / logs -p 80:8080 --name my-tomcat-container bpatterson / centos7-tomcat8 :最新的

    Nginx+Tomcat负载均衡

    最近学习Nginx+tomcat实现 负载均衡。 首先大家注意: 本文章中没有session共享,关于session共享我会在下一篇中讲解,先实现Nginx+tomcat负载均衡再实现session共享。 从网上查了好多资料,多走了很多弯路,现在把...

    Windows7系统IIS7+Tomcat集成

    "log_file"="D:\\Program Files\\Apache\\Tomcat 6.0\\logs\\isapi.log" "log_level"="debug" ;#workers.properties 物理路径 "worker_file"="D:\\Program Files\\Apache\\Tomcat 6.0\\conf\\workers.properties" ...

    I Heart Logs.pdf

    I Heart Logs.pdf I Heart Logs.pdf I Heart Logs.pdf I Heart Logs.pdf I Heart Logs.pdf I Heart Logs.pdf I Heart Logs.pdf I Heart Logs.pdf I Heart Logs.pdf I Heart Logs.pdf I Heart Logs.pdf I Heart Logs....

    How is logging implemented in OSS?

    Logs are the footprints that software systems produce during runtime, which can be used to un- derstand the dynamic behavior of these software systems. To generate logs, logging practice is accepted ...

    启动tomcat出错The Apache Tomcat Native library which allows optimal performance in production environments was not found

    TOMCAT昨天突然自己宕掉服务了,怎么重起都不行,后来查看logs中catalina.out 日志发现如下错误 INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not ...

    darks-logs 1.0.7

    darks-logsdarks-logs

Global site tag (gtag.js) - Google Analytics