On 14.03.2013 16:47, ma...@apache.org wrote: > Author: markt > Date: Thu Mar 14 15:47:24 2013 > New Revision: 1456491 > > URL: http://svn.apache.org/r1456491 > Log: > Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54660 > Allow the AccessLogValve file data format to be changed via JMX. The change > takes effect as soon as the next message is logged. > > Modified: > tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java > > 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=1456491&r1=1456490&r2=1456491&view=diff > ============================================================================== > --- tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java > (original) > +++ tomcat/trunk/java/org/apache/catalina/valves/AccessLogValve.java Thu Mar > 14 15:47:24 2013 ...
> @@ -961,6 +972,34 @@ public class AccessLogValve extends Valv > > > /** > + * Rotate the log file if necessary. > + */ > + public void rotate() { It might be nice to publish this new method via JMX. Would be useful to trigger a rotation e.g. at midnight on an idle system that would otherwise only rotate when the next access is logged. That way you can then run reliably your post rotation batches (compression, file transfer) at a defined time. Of course one can also send a dummy request to trigger rotation, but that means switching to a different type of script and might not be easily doable (network access to the right port). The other JMX accessible rotate method needs to be passed a file name which is only useful if you want to control every aspect of the rotation externally. > + if (rotatable) { > + // Only do a logfile switch check once a second, max. > + long systime = System.currentTimeMillis(); > + if ((systime - rotationLastChecked) > 1000) { > + synchronized(this) { > + if ((systime - rotationLastChecked) > 1000) { > + rotationLastChecked = systime; > + > + String tsDate; > + // Check for a change of date > + tsDate = fileDateFormatter.format(new Date(systime)); > + > + // If the date has changed, switch log files > + if (!dateStamp.equals(tsDate)) { > + close(true); > + dateStamp = tsDate; > + open(); > + } > + } > + } > + } > + } > + } > + > + /** > * Rename the existing log file to something else. Then open the > * old log file name up once again. Intended to be called by a JMX > * agent. > @@ -1091,28 +1130,8 @@ public class AccessLogValve extends Valv > * @param message Message to be logged > */ > public void log(CharArrayWriter message) { > - if (rotatable) { > - // Only do a logfile switch check once a second, max. > - long systime = System.currentTimeMillis(); > - if ((systime - rotationLastChecked) > 1000) { > - synchronized(this) { > - if ((systime - rotationLastChecked) > 1000) { > - rotationLastChecked = systime; > - > - String tsDate; > - // Check for a change of date > - tsDate = fileDateFormatter.format(new Date(systime)); > > - // If the date has changed, switch log files > - if (!dateStamp.equals(tsDate)) { > - close(true); > - dateStamp = tsDate; > - open(); > - } > - } > - } > - } > - } > + rotate(); > > /* In case something external rotated the file instead */ > if (checkExists) { Regards, Rainer --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org