In my java-server I use the java.util.logging framework to log the state of my program. To avoid a too large log file I use this Filehandler constructor:
//import java.util.logging.FileHandler;
//import java.util.logging.Logger;
FileHandler fileLog = new FileHandler("log%g.txt", 10 * 1024*1014, 2, false);
logger.addHandler(fileLog);
In my understanding the logger writes now into log0.txt until the file size is bigger than 10MB. Then he changes to log1.txt. When file size is bigger than 10 MB he changes back to log0.txt. Is this right?
So in this case the old log files will be overwritten. To avoid this I want to call a Methode (in which I send a email to the administrator), when the logger changes the output file.
void callOnOutputfileChanged() {
sendEmailToAdmin();
}
Do you have an idea how to react on this event?