private void setMongoInfoByLog4j(Project project) {
Enumeration appenders = Logger.getRootLogger().getAllAppenders();
while (appenders.hasMoreElements()) {
Object appender = appenders.nextElement();
if (appender instanceof MongoDbAppender) {
MongoDbAppender ref = (MongoDbAppender) appender;
project.setLogCollection(ref.getCollectionName());
project.setMongoUri(String.format("mongodb://%s:%s/%s",
ref.getHostname(), ref.getPort(), ref.getDatabaseName()));
}
if (appender instanceof AsynMongoURILayoutAppender) {
AsynMongoURILayoutAppender ref = (AsynMongoURILayoutAppender) appender;
project.setLogCollection(ref.getCollectionName());
project.setMongoUri(ref.getMongoURI());
}
}
}