/** * Gracefully terminate the active use of the public methods of this * component. This method should be the last one called on a given * instance of this component. * * @exception LifecycleException if this component detects a fatal error * that needs to be reported */ public void stop() throws LifecycleException { // Validate and update our current component state /** CR 6411114 (Lifecycle implementation moved to ValveBase) if (!started) throw new LifecycleException (sm.getString("extendedAccessLogValve.notStarted")); lifecycle.fireLifecycleEvent(STOP_EVENT, null); started = false; */ // START CR 6411114 if (!started) // Ignore stop if not started return; // END CR 6411114 close(); // START CR 6411114 super.stop(); // END CR 6411114 }
/** * 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. * * * @param newFileName The file name to move the log file entry to * @return true if a file was rotated with no error */ public synchronized boolean rotate(String newFileName) { if (currentLogFile!=null) { File holder = currentLogFile; close(); try { holder.renameTo(new File(newFileName)); } catch(Throwable e){ log.error("rotate failed", e); } /* Make sure date is correct */ currentDate = new Date(System.currentTimeMillis()); dateStamp = fileDateFormatter.format(currentDate); open(); return true; } else { return false; } }
close(); try { if (!holder.renameTo(new File(newFileName))) {
/** * Gracefully terminate the active use of the public methods of this * component. This method should be the last one called on a given * instance of this component. * * @exception LifecycleException if this component detects a fatal error * that needs to be reported */ public void stop() throws LifecycleException { // Validate and update our current component state if (!started) throw new LifecycleException (sm.getString("extendedAccessLogValve.notStarted")); lifecycle.fireLifecycleEvent(STOP_EVENT, null); started = false; close(); }