java.lang.ClassNotFoundException: org.apache.flume.clients.log4jappender.Log4jAppender

java.lang.ClassNotFoundException: org.apache.flume.clients.log4jappender.Log4jAppender

在使用Log4j日志信息放入到Flume时,根据官网 http://flume.apache.org/releases/content/1.9.0/FlumeUserGuide.html 的提示,在Log4j中加入如下配置信息

#...
log4j.appender.flume = org.apache.flume.clients.log4jappender.Log4jAppender
log4j.appender.flume.Hostname = example.com
log4j.appender.flume.Port = 41414
log4j.appender.flume.UnsafeMode = true

# configure a class's logger to output to the flume appender
log4j.logger.org.example.MyClass = DEBUG,flume
#...

并在root中申明了flume

log4j.rootCategory=INFO, console,flume

但在运行的时候出现如下报错

java.lang.ClassNotFoundException: org.apache.flume.clients.log4jappender.Log4jAppender

一脸蒙蔽,系统提示我缺少一个jar包。然后重新阅读官方文档时发现,官方给出了提示

java.lang.ClassNotFoundException: org.apache.flume.clients.log4jappender.Log4jAppender
根据提示,在Maven仓库中添加依赖

        <dependency>
            <groupId>org.apache.flume.flume-ng-clients</groupId>
            <artifactId>flume-ng-log4jappender</artifactId>
            <version>1.9.0</version>
        </dependency>

重新运行即可

java.lang.ClassNotFoundException: org.apache.flume.clients.log4jappender.Log4jAppenderjava.lang.ClassNotFoundException: org.apache.flume.clients.log4jappender.Log4jAppender Steve_Monster 发布了55 篇原创文章 · 获赞 1 · 访问量 1922 私信 关注
上一篇:SIX Spark Streaming 编程初级实践


下一篇:flume到底会丢数据吗?其可靠性如何?——轻松搞懂Flume事务机制