How to limit stdout.log file size when running Apache Tomcat as Windows service?

人盡茶涼 提交于 2020-01-02 01:26:46

问题


Is there any way that I could limit the size of the stdout.log file in Apache Tomcat? When running as a service system.out statements go to the stdout file. But I need to have a mechanism where I can control the size of the stdout log file by creating new files after reaching 2GB size or something like that. As of now a new file is created everyday but that is not sufficient.


回答1:


In Windows you can go to go to Program Files\Apache Software Foundation\Tomcat6.0\bin and run tomcat6w.exe as administrator Under the Java tab, in the Java Options section add the following: -Djava.util.logging.FileHandler.limit=25000000

This will set the default stdout.log file to 25MBs before it rotates to a new log file.




回答2:


If you wanted the limit to be 10 megs, you'd use the following conventions

With log4j:

 -Dlog4j.appender.R.MaxFileSize=10MB 

With JUL:

 -Djava.util.logging.FileHandler.limit=10000000

http://tomcat.apache.org/tomcat-5.5-doc/logging.html

http://docs.oracle.com/javase/1.4.2/docs/api/java/util/logging/FileHandler.html



来源:https://stackoverflow.com/questions/9070794/how-to-limit-stdout-log-file-size-when-running-apache-tomcat-as-windows-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!