错误Appender包含无效的元素或属性“ Http”

时间:2018-06-26 21:40:52

标签: log4j mule splunk

我正在使用Log4j Http附加程序通过m子cloudhub将数据发送到Splunk。在构建过程中,它会解决错误:

  

错误Appenders包含无效的元素或属性Http

我没有在Splunk中看到数据。

该错误发生在Log4j配置中:

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

在Maven构建期间,它抛出了所提到的错误。 Mule运行时版本3.8.4

其他人也遇到同样的错误吗?

整个Log4j供参考

<!--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>

1 个答案:

答案 0 :(得分:0)

the子运行时3.8.4使用的log4j2版本中不包含Http附加程序。 据我所知,运行时3.X.X中使用的最新版本是log4j2 2.8.2

enter image description here

从代码here中可以看到,它没有定义任何Http附加程序。

Http附加器已在log4j2 2.10.0(代码here)中引入,因此您有2个选择:

  • 在您的应用程序中捆绑log4j2 2.10.0版本,并尝试按照here
  • 中的说明配置类加载器覆盖
  • 从版本2.10.0中提取Http appender类及其依赖项,打包为jar并导入您的项目,请参见下图:log4j2-http-appender

希望这对您有帮助...