Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我在使用时,出现了问题 #2

Open
schooljenry opened this issue Sep 5, 2016 · 2 comments
Open

我在使用时,出现了问题 #2

schooljenry opened this issue Sep 5, 2016 · 2 comments

Comments

@schooljenry
Copy link

你好,我在使用时出现了下面的问题。是哪里出问题了?
log4j:ERROR Unexpected exception while initialising MongoDbAppender.
java.lang.NullPointerException
at com.mongodb.WriteConcern.valueOf(WriteConcern.java:399)
at com.focusit.log4jmongo.appender.SimpleMongoDbAppender.initialize(SimpleMongoDbAppender.java:392)
at com.focusit.log4jmongo.appender.SimpleMongoDbAppender.activateOptions(SimpleMongoDbAppender.java:80)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:809)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:735)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:615)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:547)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:483)
at org.apache.log4j.LogManager.(LogManager.java:127)
at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)

@d0k1
Copy link
Owner

d0k1 commented Sep 5, 2016

Hello.
I suppose you didn't set desired mongodb concern in log4j properties.
Please, take a look at example log4j configuration(log4.properties) for this appender.
log4j.appender.MongoDB.writeConcern=UNACKNOWLEDGED

@schooljenry
Copy link
Author

Thanks for your reply, I tried your method, and then there was a mistake.
2016-09-07 08:27:59
[INFO]-[Thread: main]-[com.mongodb.diagnostics.logging.SLF4JLogger.info()]: Cluster created with settings {hosts=[192.168.62.15:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}

2016-09-07 08:27:59
[INFO]-[Thread: main]-[com.mongodb.diagnostics.logging.SLF4JLogger.info()]: Adding discovered server 192.168.62.15:27017 to client view of cluster

2016-09-07 08:27:59
[INFO]-[Thread: cluster-ClusterId{value='57cf5f0f8f860f2df042360d', description='null'}-192.168.62.15:27017]-[com.mongodb.diagnostics.logging.SLF4JLogger.info()]: Opened connection [connectionId{localValue:1, serverValue:413}] to 192.168.62.15:27017

2016-09-07 08:27:59
[INFO]-[Thread: cluster-ClusterId{value='57cf5f0f8f860f2df042360d', description='null'}-192.168.62.15:27017]-[com.mongodb.diagnostics.logging.SLF4JLogger.info()]: No server chosen by PrimaryServerSelector from cluster description ClusterDescription{type=UNKNOWN, connectionMode=MULTIPLE, all=[ServerDescription{address=192.168.62.15:27017, type=UNKNOWN, state=CONNECTING}]}. Waiting for 30000 ms before timing out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants