I have the following simple Test class for DailyRollingFileAppender to rolls the log file every hour. The problem I am facing is that, it doesn't seem to roll over to new log file every hour even though I have set that to '.'yyyy-MM-dd-HH. Any idea where in the code I did wrongly?
public class Test {
static Logger logger = Logger.getLogger(Test.class);
public static void main(String args[]) throws Exception {
String pattern = "%-20d{dd MMM yyyy HH:mm:ss} [%-5p] - %m%n";
PatternLayout patternLayout = new PatternLayout(pattern);
//CREATE APPENDER.
DailyRollingFileAppender myAppender = new DailyRollingFileAppender(patternLayout, "TestOrig.log", "'.'yyyy-MM-dd-HH");
//ADD APPENDER & LEVEL.
logger.addAppender(myAppender);
logger.setLevel ((Level) Level.DEBUG);
//WRITE MESSAGES.
logger.debug("Successful");
logger.info ("Failed" );
logger.warn ("Failed" );
logger.error("Successful");
logger.fatal("Failed");
while(true)
{
Thread.sleep(1000);
}
}
}