【问题标题】:ERROR Appenders contains an invalid element or attribute "Http"错误附加程序包含无效元素或属性“Http”
【发布时间】:2018-06-26 21:40:52
【问题描述】:

我正在使用 Log4j Http appender 通过 mule cloudhub 将数据发送到 Splunk。在构建期间它会抛出错误:

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

【问题讨论】:

  • 构建失败的地方在哪里?你能告诉我们负责的代码/资源吗?
  • Log4j 配置 。在 Maven 构建期间,它会引发上述错误。 Mule 运行时版本 3.8.4
  • 请分享您的整个 log4j2.xml

标签: log4j mule splunk


【解决方案1】:

骡子运行时 3.8.4 使用的 log4j2 版本中不包含 Http appender。 据我所知,runtime 3.X.X 中使用的最新版本是 log4j2 2.8.2

从代码here 中可以看出,它没有定义任何 Http appender。

在 log4j2 2.10.0 中引入了 Http appender(代码here),所以你有两个选择:

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

希望这会有所帮助...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-21
    • 2011-04-12
    • 1970-01-01
    • 2016-12-06
    • 1970-01-01
    相关资源
    最近更新 更多