1

I am using Log4j Http appender to send data to Splunk using mule cloudhub. During the build it thorws the error:

ERROR Appenders contains an invalid element or attribute Http

and I am not seeing the data in Splunk.

The error happens with Log4j Configuration:

<Http name="Splunktest" url="myurl" token="mytoken"  
disableCertificateValidation="true"></Http>

During the maven build it is throwing the mentioned error. Mule runtime version 3.8.4

Did anyone else face the same error?

Entire Log4j for reference

<!--These are some of the loggers you can enable. 
    There are several more you can find in the documentation. 
    Besides this log4j configuration, you can also use Java VM environment variables
    to enable other logs like network (-Djavax.net.debug=ssl or all) and 
    Garbage Collector (-XX:+PrintGC). These will be append to the console, so you will 
    see them in the mule_ee.log file. -->


<Appenders>
    <RollingFile name="file" fileName="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}splunk.log" 
             filePattern="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}splunk-%i.log">
        <PatternLayout pattern="%d [%t] %-5p %c - %m%n" />
        <SizeBasedTriggeringPolicy size="10 MB" />
        <DefaultRolloverStrategy max="10"/>
    </RollingFile>

    <Http name="Splunktest" url="myurl" token="mytoken" disableCertificateValidation="true"></Http>

</Appenders>

<Loggers>


    <!-- Http Logger shows wire traffic on DEBUG -->
    <AsyncLogger name="org.mule.module.http.internal.HttpMessageLogger" level="WARN"/>

    <!-- JDBC Logger shows queries and parameters values on DEBUG -->
    <AsyncLogger name="com.mulesoft.mule.transport.jdbc" level="WARN"/>

    <!-- CXF is used heavily by Mule for web services -->
    <AsyncLogger name="org.apache.cxf" level="WARN"/>

    <!-- Apache Commons tend to make a lot of noise which can clutter the log-->
    <AsyncLogger name="org.apache" level="WARN"/>

    <!-- Reduce startup noise -->
    <AsyncLogger name="org.springframework.beans.factory" level="WARN"/>

    <!-- Mule classes -->
    <AsyncLogger name="org.mule" level="INFO"/>
    <AsyncLogger name="com.mulesoft" level="INFO"/>

    <!-- Reduce DM verbosity -->
    <AsyncLogger name="org.jetel" level="WARN"/>
    <AsyncLogger name="Tracking" level="WARN"/>

    <AsyncRoot level="INFO">
        <AppenderRef ref="file" />
    </AsyncRoot>
     <AsyncLogger name="splunk.logger" level="INFO" >
      <AppenderRef ref="Splunktest" />

    </AsyncLogger>
</Loggers>

Mukesh Kumar
  • 21
  • 1
  • 5

1 Answers1

0

The Http appender is not included in the log4j2 version used by the mule runtime 3.8.4. As far as I know the latest version used in runtime 3.X.X is log4j2 2.8.2

enter image description here

and as you can see from the code here it doesn't define any Http appender.

The Http appender has been introduced in log4j2 2.10.0 ( code here) so you have 2 options:

  • bundle in you application the log4j2 version 2.10.0 and try to configure the classloader override as explained here
  • extract the Http appender class and it's dependencies from the version 2.10.0, package as a jar and import in your project, see picture below:log4j2-http-appender

Hope this helps ...

Mario Cairone
  • 1,071
  • 7
  • 11