I have an application which uses JDK Logging with a logging.properties file which configures a number of older log-file via java.util.logging.FileHandler.count.
At certain points in the application I would like to trigger a manual rollover of the logfile to have a new logfile started, e.g. before a scheduled activity starts.
Is this possible with JDK Logging?
In Log4j I am using the following, however in this case I would like to use JDK Logging!
Logger logger = Logger.getRootLogger();
Enumeration<Object> appenders = logger.getAllAppenders();
while(appenders.hasMoreElements()) {
Object obj = appenders.nextElement();
if(obj instanceof RollingFileAppender) {
((RollingFileAppender)obj).rollOver();
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…