3 Replies Latest reply on Feb 5, 2018 12:20 PM by jamezp

    jboss EAP 6.4 json logging issues

    rajajboss

      Dear All,

       

      I am facing two issues when I am LOGGING the LOG MESSAGES in JSON FORMAT under logstash node through rsyslog node .

      jboss logging flow is like this.

      JBOSS SERVER------>RSYSLOG------->LOGSTASH

      FIRST ISSUE:

      How to use the thowable logging pattern in jboss EAP 6.4. you can refer the https://docs.jboss.org/jbossas/javadoc/7.1.2.Final/org/apache/log4j/EnhancedPatternLayout.htmllink.

      throwable

      Used to output the Throwable trace that has been bound to the LoggingEvent, by default this will output the full trace as one would normally find by a call to Throwable.printStackTrace(). %throwable{short} or %throwable{1} will output the first line of stack trace. throwable{none} or throwable{0} will suppress the stack trace. %throwable{n} will output n lines of stack trace if a positive integer or omit the last -n lines if a negative integer. If no %throwable pattern is specified, the appender will take responsibility to output the stack trace as it sees fit.

      I have tried "throwbale" pattern like below under JBOSS EAP 6.4: this configuration took from standalone.xml

      standalone.xml

       <custom-handler name="RSYSLOG" class="org.jboss.logmanager.handlers.SyslogHandler" module="org.jboss.logmanager"> <encoding value="ISO-8859-1"/> <formatter> <pattern-formatter pattern="{ &quot;thread_name&quot;:&quot;%t&quot;, &quot;thread_id&quot;:&quot;%t&quot;, &quot;class_name&quot;:&quot;%C&quot;, &quot;src_file&quot;:&quot;%F&quot;, &quot;line_no&quot;:&quot;%L&quot;, &quot;message&quot;:&quot;%m&quot;, &quot;throwable&quot;:%throwable{short}&quot;, &quot;msg_type&quot;:&quot;log4j2&quot;}%n"/> </formatter> <properties> <property name="appName" value="MY_APP"/> <property name="facility" value="LOCAL_USE_4"/> <property name="serverHostname" value="localhost"/> <property name="hostname" value="localhost"/> <property name="port" value="514"/> <property name="syslogType" value="RFC3164"/> <property name="protocol" value="TCP"/> <property name="messageDelimiter" value=":"/> <property name="useMessageDelimiter" value="false"/> <property name="escapeEnabled" value="true"/> </properties> </custom-handler>

      I did not find any example in internet for throwbale logging pattern.

      SECOND ISSUE:

      I am sending message in json format from JBOSS SERVER to LOGSTASH node through RSYSLOG.

      Issue:

      As the messsages are in json format, they are failed to be parsed by the json parser at logstash node and Hence they are not logging under /var/log/logging/app.log directory of logstash node.

      I have tried escapeEnabled =true configiuration. see the above configuration for this.Still it is not working.

      observations:

      Messages having special characters like "",:,'' ,().Especially these kind of messsages are failing and NOT logging under logstash node.

      can somebody help me how to ESCAPE THE SPECIAL CHARACTERS in the the messages in THROUGH JBOSS LOGGING FORMAT.So that logs will be logged under logtstash node and we can avoid json parsing as well.

      Thanks. Raja

        • 1. Re: jboss EAP 6.4 json logging issues
          jamezp

          The first thing to point out is JBoss EAP does not use log4j as it's log manager. For an exception the pattern is "%e" or "%E". Sadly the documentation is very lacking for the JBoss Log Manager.

           

          That said using a pattern is probably not the best way to handle JSON formatting. It would probably be better to write your own custom formatter which uses a JSON library which could properly escape the messages. The current version of the JBoss Log Manager does include a JsonFormatter. It would be fairly easy to write a custom formatter like this.

           

          --

          James R. Perkins

          • 2. Re: jboss EAP 6.4 json logging issues
            rajajboss

            Hi James,

             

            Thank you very much for your reply.

             

            I saw the code jboss-logmanager/JsonFormatter.java at master · jboss-logging/jboss-logmanager · GitHub

            But I confused How to configure and use it.

            Do you have any procedure?

             

            I want to use Sysloghandler or Socket handler to send the json message to rsyslog . Is it possibe put the custom jsonformmater  under syslog handler.

             

            Would you please some more details like steps/procedure.

             

            Once again thank you very much.

             

             

             

            Thanks,

             

            Raja

            • 3. Re: jboss EAP 6.4 json logging issues
              jamezp

              You'd first have to create a module with a log manager that includes the JsonFormatter. At this point there are only alpha releases that require Java 8. I mainly linked the one in the log manager as an example of how one could be written.

               

              You're other option would be to create your own custom JsonFormatter. This would probably be the easiest solution and you could use JSON-P from Java EE 7 to create the JSON output. Note this would require you run on Java 7 though. Then you'd just create a custom-formatter and assign it to either the syslog-handler or a custom socket handler.

               

              --

              James R. Perkins