Author: rjung Date: Mon Dec 3 14:10:30 2012 New Revision: 1416529 URL: http://svn.apache.org/viewvc?rev=1416529&view=rev Log: Only rename AccessLogValve file with renameOnrotate=true if target file does not already exist.
We don't want to overwrite existing files. Prefer not to rotate. Typical case would be several ALV instances configured to use the same file name. Only the first one should rename on rotate. Modified: tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java tomcat/trunk/java/org/apache/catalina/valves/LocalStrings.properties Modified: tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java?rev=1416529&r1=1416528&r2=1416529&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java (original) +++ tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java Mon Dec 3 14:10:30 2012 @@ -1086,13 +1086,17 @@ public class AccessLogValve extends Valv writer.close(); if (rename && renameOnRotate) { File newLogFile = getLogFile(true); - try { - if (!currentLogFile.renameTo(newLogFile)) { - log.error(sm.getString("accessLogValve.renameFail", currentLogFile, newLogFile)); + if (!newLogFile.exists()) { + try { + if (!currentLogFile.renameTo(newLogFile)) { + log.error(sm.getString("accessLogValve.renameFail", currentLogFile, newLogFile)); + } + } catch (Throwable e) { + ExceptionUtils.handleThrowable(e); + log.error(sm.getString("accessLogValve.renameFail", currentLogFile, newLogFile), e); } - } catch (Throwable e) { - ExceptionUtils.handleThrowable(e); - log.error(sm.getString("accessLogValve.renameFail", currentLogFile, newLogFile), e); + } else { + log.error(sm.getString("accessLogValve.alreadyExists", currentLogFile, newLogFile)); } } writer = null; Modified: tomcat/trunk/java/org/apache/catalina/valves/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/valves/LocalStrings.properties?rev=1416529&r1=1416528&r2=1416529&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/valves/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/catalina/valves/LocalStrings.properties Mon Dec 3 14:10:30 2012 @@ -23,6 +23,7 @@ accessLogValve.closeFail=Failed to close accessLogValve.openDirFail=Failed to create directory [{0}] for access logs accessLogValve.rotateFail=Failed to rotate access log accessLogValve.renameFail=Failed to rename access log from [{0}] to [{1}] +accessLogValve.alreadyExists=Failed to rename access log from [{0}] to [{1}], file already exists. accessLogValve.invalidLocale=Failed to set locale to [{0}] accessLogValve.unsupportedEncoding=Failed to set encoding to [{0}], will use the system default character set. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org