![JAR search and dependency download from the Maven repository](/logo.png)
org.zeroturnaround.javarebel.integration.log4j.Log4jReloader Maven / Gradle / Ivy
The newest version!
package org.zeroturnaround.javarebel.integration.log4j;
import org.zeroturnaround.javarebel.ClassEventListener;
import org.zeroturnaround.javarebel.LoggerFactory;
import java.net.URL;
import java.io.File;
/**
*
* @author Richard Julien
* @version 1.0
*/
public class Log4jReloader {
/** Log4j file last modified time. */
private static long lastModifiedTime;
/** Log4j file name. */
private static String log4jFilename;
/**
* Check file modification time.
*
* @param url
* the file url
*/
public static void checkFileModifiedTime(URL url) {
log4jFilename = url.getFile();
lastModifiedTime = getModifiedTime();
}
/**
* Check if configuration must be reloaded.
*
* @return true or false
*/
public static boolean mustReload() {
if (getModifiedTime() > lastModifiedTime) {
LoggerFactory.getInstance().echo("[JRebel-Log4j] **** RELOADING Log4j CONFIGURATION ****");
lastModifiedTime = getModifiedTime();
return true;
}
return false;
}
/**
* Get the last modified time.
*
* @return the time in long format
*/
private static long getModifiedTime() {
File log4jFile = new File(log4jFilename);
return log4jFile.lastModified();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy