jjchiw / gelf4net

GELF log4net Appender - graylog2
MIT License
63 stars 59 forks source link

Data in a wrong format in Graylog? #57

Closed gabriel-a closed 6 years ago

gabriel-a commented 6 years ago

I have a simple installation of RabbitMQ with Graylog.

The configuration is:

<log4net name="log4netelk">
    <appender name="AsyncGelfAmqpAppender" type="Gelf4Net.Appender.AsyncGelfAmqpAppender, Gelf4Net.AmqpAppender">
      <remoteAddress value="localhost" />
      <remotePort value="5672" />
      <username value="admin" />
      <password value="password" />
      <virtualHost value="/" />
      <exchange value="log-messages" />
      <key value="#" />
      <layout type="Gelf4Net.Layout.GelfLayout, Gelf4Net.AmqpAppender">
        <param name="AdditionalFields" value="app:ElectionApplication,version:1.0,Level:%level" />
        <param name="Facility" value="RandomPhrases" />
        <param name="IncludeLocationInformation" value="true" />
        <param name="SendTimeStampAsString" value="false" />
        <!-- Sets the full_message and short_message to the specified pattern-->
        <!--        <param name="ConversionPattern" value="[%t] %c{1} - %m" />-->
      </layout>
    </appender>
    <appender name="TraceAppender" type="log4net.Appender.TraceAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%-4timestamp [%thread] %-5level %logger %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="ALL" />
      <appender-ref ref="AsyncGelfAmqpAppender" />
      <appender-ref ref="TraceAppender" />
    </root>
  </log4net>

But the data coming in graylog: message ��Q�N�@����^�ҭ���T +4 � y�Gٰ�mvb�w�R�1ē��7o&3o?�B�5d\p{pb��@�T�n44����k�)flaP�r��cs��26�RU�d= � �?�[�����˕�$ ��t������V��7r�s��2�N1�_ަ���s: FA� ܣ��}r�D�Q�[^��P�Ք4��~�FnԿ�O;��Z��ѹ^+LT���@��]��������|ԝ�*���q�[�W�j��ډ�%~��{�G#B����AD�Wr����f�u3����-��� 6҇�<k�7.k�����'��������ab

Any idea what im doing wrong?

jjchiw commented 6 years ago

Hi

Have you tried with another appender?

What version of graylog are you using?

I'll try to reproduce the error, during the week

gabriel-a commented 6 years ago

I did with another appender, and i have one that is written by myself all send normal json data. I'm not really sure why this is happening. Most probably i missed something.

jjchiw commented 6 years ago

Maybe it's something with "zipping" the payload (gelf)

From the docs (http://docs.graylog.org/en/2.4/pages/gelf.html?highlight=gzip):

When using UDP as transport layer, GELF messages can be sent uncompressed or compressed with either GZIP or ZLIB.

But I'm sure this was working with AMQP....... I'll add a flag to zip or not the message....

I'll let you know when I upgrade the nuget package :)

jjchiw commented 6 years ago

I run some tests using AMQP appender and I can't reproduce the error....

gabriel-a commented 6 years ago

After checking the data, it was sent correctly and received wrong.

I did some debug, and found out a third party in between that was causing it. Its fixed now i made it directly