//make sure we reset the file
if (appender != null)
{
try
{
RollingFileAppender fileAppender = RollingFileAppender.class.cast(appender);
//reset the logfile if necessary
if (!fileAppender.getFile().equals(commLogFile_))
{
logger.info("Reseting comm log file destination. Old file: " + fileAppender.getFile()
+ ". New file: " + commLogFile_);
fileAppender.setFile(commLogFile_);
fileAppender.activateOptions();
}
}
catch (Exception ex)
{
logger.warn("Can not verify the current comm log appender. "
+ "It will deleted and new one created with default setting");
//delete the appender and recreate a new one
logger.removeAppender(appender);
appender = null;
}
}
// create a new appender with default setting!
if (null == appender)
{
RollingFileAppender fileAppender = new RollingFileAppender();
fileAppender.setName("DataStoreCommAppender");
fileAppender.setMaxFileSize("100KB");
fileAppender.setMaxBackupIndex(10);
PatternLayout layout = new PatternLayout("%-5p %d{dd MMM yyyy HH:mm:ss} [%x] %m%n");
fileAppender.setLayout(layout);
fileAppender.setFile(commLogFile_);
fileAppender.activateOptions();
// add into the logger
logger.addAppender(fileAppender);
}
return logger;