2014-12-03 58 views
0

我想在Mahout中运行2newsgroup分类示例。我已经设置MAHOUT_LOCAL = TRUE,分类不显示混淆矩阵,并给出以下警告:如何解决“log4j:警告没有appender可以发现记录器”错误在二十新闻组分类示例

ok. You chose 1 and we'll use cnaivebayes 
creating work directory at /tmp/mahout-work-cloudera 
+ echo 'Preparing 20newsgroups data' 
Preparing 20newsgroups data 
+ rm -rf /tmp/mahout-work-cloudera/20news-all 
+ mkdir /tmp/mahout-work-cloudera/20news-all 
+ cp -R /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/alt.atheism /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/comp.graphics /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/comp.os.ms-windows.misc /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/comp.sys.ibm.pc.hardware /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/comp.sys.mac.hardware /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/comp.windows.x /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/misc.forsale /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/rec.autos /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/rec.motorcycles /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/rec.sport.baseball /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/rec.sport.hockey /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/sci.crypt /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/sci.electronics /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/sci.med /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/sci.space /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/soc.religion.christian /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/talk.politics.guns /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/talk.politics.mideast /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/talk.politics.misc /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-test/talk.religion.misc /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/alt.atheism /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/comp.graphics /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/comp.os.ms-windows.misc /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/comp.sys.ibm.pc.hardware /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/comp.sys.mac.hardware /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/comp.windows.x /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/misc.forsale /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/rec.autos /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/rec.motorcycles /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/rec.sport.baseball /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/rec.sport.hockey /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/sci.crypt /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/sci.electronics /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/sci.med /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/sci.space /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/soc.religion.christian /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/talk.politics.guns /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/talk.politics.mideast /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/talk.politics.misc /tmp/mahout-work-cloudera/20news-bydate/20news-bydate-train/talk.religion.misc /tmp/mahout-work-cloudera/20news-all 
+ '[' '' '!=' '' ']' 
+ echo 'Creating sequence files from 20newsgroups data' 
Creating sequence files from 20newsgroups data 
+ ./bin/mahout seqdirectory -i /tmp/mahout-work-cloudera/20news-all -o /tmp/mahout-work-cloudera/20news-seq -ow 
MAHOUT_LOCAL is set, so we don't add HADOOP_CONF_DIR to classpath. 
MAHOUT_LOCAL is set, running locally 
SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J: Found binding in [jar:file:/home/cloudera/mahout-master/examples/target/mahout-examples-1.0-SNAPSHOT-job.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: Found binding in [jar:file:/home/cloudera/mahout-master/examples/target/dependency/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 
log4j:WARN No appenders could be found for logger (org.apache.mahout.common.AbstractJob). 
log4j:WARN Please initialize the log4j system properly. 
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 
+ echo 'Converting sequence files to vectors' 
Converting sequence files to vectors 
+ ./bin/mahout seq2sparse -i /tmp/mahout-work-cloudera/20news-seq -o /tmp/mahout-work-cloudera/20news-vectors -lnorm -nv -wt tfidf 
MAHOUT_LOCAL is set, so we don't add HADOOP_CONF_DIR to classpath. 
MAHOUT_LOCAL is set, running locally 
SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J: Found binding in [jar:file:/home/cloudera/mahout-master/examples/target/mahout-examples-1.0-SNAPSHOT-job.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: Found binding in [jar:file:/home/cloudera/mahout-master/examples/target/dependency/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 
log4j:WARN No appenders could be found for logger (org.apache.mahout.vectorizer.SparseVectorsFromSequenceFiles). 
log4j:WARN Please initialize the log4j system properly. 
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 
+ echo 'Creating training and holdout set with a random 80-20 split of the generated vector dataset' 
Creating training and holdout set with a random 80-20 split of the generated vector dataset 
+ ./bin/mahout split -i /tmp/mahout-work-cloudera/20news-vectors/tfidf-vectors --trainingOutput /tmp/mahout-work-cloudera/20news-train-vectors --testOutput /tmp/mahout-work-cloudera/20news-test-vectors --randomSelectionPct 40 --overwrite --sequenceFiles -xm sequential 
MAHOUT_LOCAL is set, so we don't add HADOOP_CONF_DIR to classpath. 
MAHOUT_LOCAL is set, running locally 
SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J: Found binding in [jar:file:/home/cloudera/mahout-master/examples/target/mahout-examples-1.0-SNAPSHOT-job.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: Found binding in [jar:file:/home/cloudera/mahout-master/examples/target/dependency/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 
log4j:WARN No appenders could be found for logger (org.apache.mahout.driver.MahoutDriver). 
log4j:WARN Please initialize the log4j system properly. 
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 
+ echo 'Training Naive Bayes model' 
Training Naive Bayes model 
+ ./bin/mahout trainnb -i /tmp/mahout-work-cloudera/20news-train-vectors -el -o /tmp/mahout-work-cloudera/model -li /tmp/mahout-work-cloudera/labelindex -ow -c 
MAHOUT_LOCAL is set, so we don't add HADOOP_CONF_DIR to classpath. 
MAHOUT_LOCAL is set, running locally 
SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J: Found binding in [jar:file:/home/cloudera/mahout-master/examples/target/mahout-examples-1.0-SNAPSHOT-job.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: Found binding in [jar:file:/home/cloudera/mahout-master/examples/target/dependency/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 
log4j:WARN No appenders could be found for logger (org.apache.mahout.driver.MahoutDriver). 
log4j:WARN Please initialize the log4j system properly. 
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 
+ echo 'Self testing on training set' 
Self testing on training set 
+ ./bin/mahout testnb -i /tmp/mahout-work-cloudera/20news-train-vectors -m /tmp/mahout-work-cloudera/model -l /tmp/mahout-work-cloudera/labelindex -ow -o /tmp/mahout-work-cloudera/20news-testing -c 
MAHOUT_LOCAL is set, so we don't add HADOOP_CONF_DIR to classpath. 
MAHOUT_LOCAL is set, running locally 
SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J: Found binding in [jar:file:/home/cloudera/mahout-master/examples/target/mahout-examples-1.0-SNAPSHOT-job.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: Found binding in [jar:file:/home/cloudera/mahout-master/examples/target/dependency/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 
log4j:WARN No appenders could be found for logger (org.apache.mahout.driver.MahoutDriver). 
log4j:WARN Please initialize the log4j system properly. 
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 
+ echo 'Testing on holdout set' 
Testing on holdout set 
+ ./bin/mahout testnb -i /tmp/mahout-work-cloudera/20news-test-vectors -m /tmp/mahout-work-cloudera/model -l /tmp/mahout-work-cloudera/labelindex -ow -o /tmp/mahout-work-cloudera/20news-testing -c 
MAHOUT_LOCAL is set, so we don't add HADOOP_CONF_DIR to classpath. 
MAHOUT_LOCAL is set, running locally 



SLF4J: Class path contains multiple SLF4J bindings. 
SLF4J: Found binding in [jar:file:/home/cloudera/mahout-master/examples/target/mahout-examples-1.0-SNAPSHOT-job.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: Found binding in [jar:file:/home/cloudera/mahout-master/examples/target/dependency/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] 
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. 
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 



log4j:WARN No appenders could be found for logger (org.apache.mahout.driver.MahoutDriver). 
log4j:WARN Please initialize the log4j system properly. 
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 

请给我任何解决方案感谢。

回答

3

很多小时的搜索后,我发现这个解决方案:

创建log4j.properties文件

这是主要的属性文件具有log4j的使用的所有运行时配置。该文件将具有appender信息,文件appender的日志级别信息和输出文件名称。

log4j.rootLogger=DEBUG,consoleAppender, fileAppender 
log4j.appender.consoleAppender=org.apache.log4j.ConsoleAppender 
log4j.appender.consoleAppender.layout=org.apache.log4j.PatternLayout 
log4j.appender.consoleAppender.layout.ConversionPattern=[%t] %-5p %c %x - %m%n 
log4j.appender.fileAppender=org.apache.log4j.RollingFileAppender 
log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout 
log4j.appender.fileAppender.layout.ConversionPattern=[%t] %-5p %c %x - %m%n 
log4j.appender.fileAppender.File=demoApplication.log 

这个错误“log4j.properties”文件是由于缺少你可以找到关于这个更多的信息:http://www.tutorialspoint.com/log4j/log4j_configuration.htm

相关问题