I am trying to insert my application logs into MongoDB. I have created a custom appender and have overridden the append method as follows:
public void append(LoggingEvent loggingEvent) {
Document doc = convertToMongoDocument(loggingEvent);
pushDocToDB(doc);
}
public Document convertToMongoDocument(LoggingEvent event) {
Document doc = new Document();
// will read from the actual logging event later
doc.append("logger", "logger");
doc.append("user", "user");
doc.append("message", "message");
doc.append("timestamp", "timestamp");
return doc;
}
public void pushDocToDB(Document docList) {
getCollection().insertOne(docList);
}
I keep running into the below error when trying to insert a document from a java client. I have not created any replica sets and am using a standalone instance of MongoDB in my local.
No server chosen by WritableServerSelector from cluster description ClusterDescription{type=UNKNOWN, connectionMode=SINGLE, all=[ServerDescription{address=localhost:27017, type=UNKNOWN, state=CONNECTING}]}. Waiting for 1000000 ms before timing out
I am using mongo-java-driver - version 3.4.0 and jdk 1.7