tomcat自动切割日志(Windows)

第一步:获取cronolog

下载cronolog-win32

第二步:解压后把cronolog.exe放在tomcat的bin目录下

第三步:修改tomcat的startup.bat文件

call "%EXECUTABLE%"start %CMD_LINE_ARGS%

替换为

call "%EXECUTABLE%" run %CMD_LINE_ARGS%

第四步:修改tomcat的catalina.bat文件

在最后几行加上,下图红色箭头标示的每行末尾 加上 红色字体部分

rem Execute Java with the applicable properties
if not "%JPDA%" == "" goto doJpda
if not "%SECURITY_POLICY_FILE%" == "" goto doSecurity
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION%|D:\apache-tomcat-7.0.54\bin\cronolog.exe D:\logs\catalina.%%Y-%%m-%%d.out
goto end
:doSecurity
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% |D:\apache-tomcat-7.0.54\bin\cronolog.exe D:\logs\catalina.%%Y-%%m-%%d.out
goto end
:doJpda
if not "%SECURITY_POLICY_FILE%" == "" goto doSecurityJpda
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% |D:\apache-tomcat-7.0.54\bin\cronolog.exe D:\logs\catalina.%%Y-%%m-%%d.out
goto end
:doSecurityJpda
%_EXECJAVA% %JAVA_OPTS% %CATALINA_OPTS% %JPDA_OPTS% %DEBUG_OPTS% -Djava.endorsed.dirs="%JAVA_ENDORSED_DIRS%" -classpath "%CLASSPATH%" -Djava.security.manager -Djava.security.policy=="%SECURITY_POLICY_FILE%" -Dcatalina.base="%CATALINA_BASE%" -Dcatalina.home="%CATALINA_HOME%" -Djava.io.tmpdir="%CATALINA_TMPDIR%" %MAINCLASS% %CMD_LINE_ARGS% %ACTION% |D:\apache-tomcat-7.0.54\bin\cronolog.exe D:\logs\catalina.%%Y-%%m-%%d.out
goto end

tomcat自动切割日志(Windows)_第1张图片

第五步:重启

在指定目录下会生成对应日期的文件,修改系统时间测试跨天后是否自动生成第二天文件

你可能感兴趣的:(Tomcat)