// open file target in append mode
final File appfile = new File(prop.getProperty("logs.dir")
+ File.separator + IConst.LOG.APPLICATION_LOG_NAME);
appLoggerTargets[1] = new RotatingFileTarget(true,
appformatter, new RotateStrategyByDate(),
new UniqueFileStrategy(appfile, ".yyyy-MM-dd", ".log"));
}
//Set log targets of logger
appLogger.setLogTargets(appLoggerTargets);
//*************************** create and configure audit logger
auditLogger = Hierarchy.getDefaultHierarchy().getLoggerFor(
IConst.LOG.AUDIT_LOG_NAME);
auditLogger.setPriority(Priority.INFO);
final PatternFormatter auditformatter = new PatternFormatter(prop
.getProperty("logs.pattern.audit"));
LogTarget[] auditLoggerTargets = new LogTarget[writeToFile ? 2 : 1];
// create JDBC target
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("jgossip_db");
auditLoggerTargets[0] = new DefaultJDBCTarget(ds,
IConst.LOG.LOG_TABLE, IConst.LOG.LOG_COLUMNS);
if (writeToFile) {
// open file target in append mode
final File auditfile = new File(prop.getProperty("logs.dir")
+ File.separator + IConst.LOG.AUDIT_LOG_NAME);
auditLoggerTargets[1] = new RotatingFileTarget(
true,
auditformatter,
new RotateStrategyByDate(),
new UniqueFileStrategy(auditfile, ".yyyy-MM-dd", ".log"));
}
//Set log targets of logger
auditLogger.setLogTargets(auditLoggerTargets);