使用带有Flume的Log4j2发送文本消息

时间:2015-02-10 09:33:47

标签: hadoop log4j bigdata log4j2 flume

我有Log4j2配置:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appenders>

        <Console name="console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d %-5p - %m%n"/>
        </Console>
      <Flume name="flume" >
            <MarkerFilter marker="FLUME" onMatch="ACCEPT" onMismatch="DENY"/>
            <Agent host="IP_HERE" port="6999"/>
      </Flume>
      <File name="file" fileName="flume.log">
            <MarkerFilter marker="FLUME" onMatch="ACCEPT" onMismatch="DENY"/>
        </File>      
    </appenders>

    <loggers>
        <root level="info">
            <appender-ref ref="file"/>
            <appender-ref ref="console"/>
         <appender-ref ref="flume"/>
        </root>

    </loggers>
</configuration>

Flume代理商:

agent1.channels = ch1
agent1.sources = avro-source1
agent1.sinks = hdfs-sink1

agent1.channels.ch1.type = memory

agent1.sources.avro-source1.type = avro
agent1.sources.avro-source1.bind = IP_HERE
agent1.sources.avro-source1.port = 6999

agent1.sinks.hdfs-sink1.type = hdfs
agent1.sinks.hdfs-sink1.hdfs.path = hdfs://hadoop/user/hduser/bond/flume
agent1.sinks.hdfs-sink1.hdfs.fileType = DataStream
agent1.sinks.hdfs-sink1.hdfs.writeFormat = Text


agent1.sinks.hdfs-sink1.channel = ch1
agent1.sources.avro-source1.channels = ch1

当我发送日志时,第一次在我的Web服务器控制台上出现错误:&#34; ERROR递归调用appender flume&#34;,(Flume Agent处于活动状态并且已正确进行绑定过程)记录器事件没有错误,并且文件写在hadoop上,但是当我尝试在文本模式下使用HUE将其可视化时,我可以查看我发送的文本,我只看到二进制代码... 有什么错吗?或者我必须这样做,我可以在文本模式下编写文件? 谢谢

1 个答案:

答案 0 :(得分:0)

一样简单:

而不是:

 <Flume name="flume" >

时:

<Flume name="flume" compress="false" type="Avro">

感谢好example