使用gelf4net将amqp发送到graylog

时间:2015-05-19 13:25:32

标签: log4net graylog

任何人都知道是否可以使用gelf4net将GELF AMQP消息直接发送到Graylog?

我可以看到关于使用旧的graylog2无线电订阅rabbitmq或类似经纪人的旧帖子。但随后发现this post表示它已经内置于graylog v1。

gelf4net设置看起来很简单 - 但如何在Graylog中设置GELF AMQP输入?

1 个答案:

答案 0 :(得分:0)

3年后的乌夫...

我不在StackOverflow中搜索gelf4net问题:/,因为通常我在github中都不会回答很多问题。

这是log4net.config

<log4net>
    <appender name="GelfAmqpAppender" type="Gelf4Net.Appender.GelfAmqpAppender, Gelf4Net.AmqpAppender">
        <remoteAddress value="127.0.0.1" />
        <remotePort value="5672" />
        <username value="guest" />
        <password value="guest" />
        <virtualHost value="/" />
        <exchange value="log-messages" />
        <key value="#" />
        <layout type="Gelf4Net.Layout.GelfLayout, Gelf4Net.AmqpAppender">
            <param name="AdditionalFields" value="app:GelfAmqpAppender,version:1.0,Level:%level" />
            <param name="Facility" value="RandomPhrases" />
            <param name="IncludeLocationInformation" value="true" />
            <!-- Sets the full_message and short_message to the specified pattern-->
            <!--<param name="ConversionPattern" value="[%t] %c{1} - %m" />-->
        </layout>
    </appender>

    <appender name="AsyncGelfAmqpAppender" type="Gelf4Net.Appender.AsyncGelfAmqpAppender, Gelf4Net.AmqpAppender">
        <remoteAddress value="127.0.0.1" />
        <remotePort value="5672" />
        <username value="guest" />
        <password value="guest" />
        <virtualHost value="/" />
        <exchange value="log-messages" />
        <key value="#" />
        <layout type="Gelf4Net.Layout.GelfLayout, Gelf4Net.AmqpAppender">
            <param name="AdditionalFields" value="app:AsyncGelfAmqpAppender,version:1.0,Level:%level" />
            <param name="Facility" value="RandomPhrases" />
            <param name="IncludeLocationInformation" value="true" />
            <!-- Sets the full_message and short_message to the specified pattern-->
            <!--<param name="ConversionPattern" value="[%t] %c{1} - %m" />-->
        </layout>
    </appender>

    <root>
        <level value="ALL" />
        <appender-ref ref="GelfAmqpAppender" />
        <appender-ref ref="AsyncGelfAmqpAppender" />
    </root>
</log4net>

属性<exchange value="log-messages" />应该在RabbitMQ控制台中创建Exchange和名为Queue的{​​{1}}

enter image description here enter image description here

这是Graylog中的输入配置

enter image description here enter image description here

此配置是我的开发环境,您应该深入了解RabbitMQ和Graylog以获取最佳配置