0
我已經在eclipse win7 64bit上運行mongDb上的morphia。
唸叨log4mongo這裏:
http://log4mongo.org/display/PUB/Log4mongo+for+Java
以下步驟,但得到這樣的:爲什麼我不能啓動log4j(新手)
log4j:ERROR Could not instantiate class [com.google.code.log4mongo.MongoDbAppender].
java.lang.ClassNotFoundException: com.google.code.log4mongo.MongoDbAppender
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.log4j.helpers.Loader.loadClass(Loader.java:198)
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(OptionConverter.java:326)
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(OptionConverter.java:123)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:752)
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.<clinit>(LogManager.java:127)
at org.apache.log4j.Logger.getLogger(Logger.java:117)
at LogTest.main(LogTest.java:6)
log4j:ERROR Could not instantiate appender named "MongoDB".
log4j:WARN No appenders could be found for logger (LogTest).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
我有log4j.properties在我的日食bin文件夾(也許錯了,但沒有得到響應的其他地方)。
此文件是importet:
log4mongo-java的0.7.0.jar
的log4j-1.2.16.jar
蒙戈-2.6.5.jar
這是log4j.properties:
log4j.rootLogger=error, MongoDB
log4j.appender.MongoDB=com.google.code.log4mongo.MongoDbAppender
log4j.appender.MongoDB.databaseName=appname
log4j.appender.MongoDB.collectionName=log
林也startet是在等待連接
這裏蒙戈殼牌公司的首發:
import org.apache.log4j.Logger;
public class LogTest {
public static void main(String[] args) {
Logger logger = Logger.getLogger(LogTest.class);
logger.error("Don't panic");
}
}
這個工作正常
log4j.rootLogger=error, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
我更改爲org.log4mongo.MongoDbAppender,我使用log4mongo-java-0.7.0.jar。錯誤消失了。使用MongoVue但不能看到appname或任何日誌ducument然而。也許免費版的mongoVue只顯示一個分區 – Erik
文檔在這裏 - >「https://github.com/RobertStewart/log4mongo-java/blob/master/log4j.properties.sample」。但我不能解釋mongoVue,對不起。 –
現在得到它的工作謝謝 – Erik