如何在Apache Camel> = 3中配置路由跟踪?

多彩的:

我正在尝试从Camel 2.X迁移到3.X,并遇到了有关记录路由跟踪的问题。以前,我已经在我的应用程序上下文xml文件中像这样配置它:

<bean id="camelTracer" class="org.apache.camel.processor.interceptor.Tracer">
    <property name="traceExceptions" value="false" />
    <property name="traceInterceptors" value="true" />
    <property name="logLevel" value="DEBUG" />
    <property name="logName" value="com.mycompany.routing.trace" />
</bean>

<bean id="traceFormatter" class="org.apache.camel.processor.interceptor.DefaultTraceFormatter">
    <property name="showBody" value="true" />
    <property name="maxChars" value="0" />
</bean>

但这显然行不通了。从Camel网站上的迁移指南中:

“已实现了新的跟踪器,并且已删除了旧的跟踪器。新的跟踪器将消息记录在org.apache.camel。跟踪记录器名称是经过硬编码的。输出的格式也进行了更新,以使其更好。跟踪器可以定制。”

如果我.tracing()在路线的起点设置,则会记录跟踪。名称是硬编码的,这很好,但是除其他外,我想将级别从INFO更改为DEBUG。

有谁知道在哪里可以找到有关如何配置此“新”跟踪器的信息(最好在applicationContext.xml文件中)?还是其他地方,也许在Java DSL路由中?还是有可能?

谢谢!

床:

的日志记录级别DefaultTracer无法通过配置更改。您需要实现自定义Tracer并将此实现绑定到注册表。

示踪剂:

public class TracerCustom extends DefaultTracer {
    private static final Logger LOG = LoggerFactory.getLogger("com.stackoverflow.camel.TracerCustom");

    @Override
    protected void dumpTrace(String out) {
        LOG.debug(out);
    }
    // Customize other methods if needed
}

春天的背景:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <bean class="com.stackoverflow.camel.TracerCustom" />

  <camelContext id="tracerCamelContext" xmlns="http://camel.apache.org/schema/spring">
    <route trace="true">
      <from uri="timer:test"/>
      <to uri="log:test"/>
    </route>
  </camelContext>

</beans>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Apache Camel:如何在doCatch()块中获取异常消息?

如何在Apache Camel中测试多个RouteBuilder

如何在 Apache Camel 3.XX 路由上设置标头?

如何定义到InfluxDB的Apache Camel路由

Apache Camel-路由交易

Apache Camel 超时同步路由

如何从Apache Camel中的curl获得结果?

如何在几种Apache Camel路由中包含常见行为?

Apache Camel Kafka:如何在Producer配置上设置属性“ delivery.request.ms”

如何测试从目录中读取的 Camel 路由?

在apache-camel中,如何在FTP网址中嵌入FTP命令?

如何在apache-karaf-4.0.4中安装camel-osgi

如何在Apache Camel + Spring中动态加载属性文件值

如何在集群环境中通过 Zookeeper 和 ActiveMQ 使用 Apache Camel

如何在 apache camel DSL 或骆驼处理器中设置额外的身份验证属性?

使用Apache Camel AWS-KINESIS终端节点,如何在Kinesis流中检查消息?

如何在apache camel spring xml中创建MAP属性值?

如何在Apache Camel中设置避免调用最终化?

如何在Spring Boot中为Camel配置Jackson ObjectMapper

NoClassDefFoundError:Apache Camel中的ComponentExtension

Apache Camel中的TypeConversion错误

Apache Camel Route 中的动态 to()

在Apache Camel中组播

Apache Camel中的Ping服务

Apache Camel 2.18中的IN子句

如何使Apache Camel在“直接”路由的末尾删除文件?

Apache Camel FTP-如何手动启动路由

如何定义“来自SOAP Web服务”的Apache Camel路由?

如何找到路由的所有端点(Apache Camel,Java)