利用log4mongo-java+mongodb複製集搭建java日誌系統
The log4mongo-java 0.6 release added full support for replica sets. While earlier releases would work with replica sets, you could specify only one host in the hostname property. If the appender happened to be initialized when that host was not available, the appender would not be able to connect to other members of the set.
With the 0.6 release, you should specify the names of all the hosts that can become master. The Mongo Java driver will automatically find the current master. For example:
log4j.appender.MongoDB.hostname=mongo1.example.com mongo2.example.com
If MongoDB is listening on the same port on each host, you can specify just that port. If it's the default port of 27017, you can omit the property.
log4j.appender.MongoDB.port=27000
If the same port is not used by each host, then you must specify the port for all hosts. For example, if the hosts mongo1 and mongo2 are listening on 27000 and 28000, respectively:
log4j.appender.MongoDB.port=27000 28000
When a master becomes available, the next attempt to log will fail and the insert will be lost. The Mongo driver will then check for the new master and the next insert should go to the new master. Log inserts between the time of the original master's failure and the election of the new master will be lost.