[英]How to configure route tracing in 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 記錄器名稱中記錄消息,這是硬編碼的。output 的格式也被更新以使其更好。跟蹤器可以定制。”
如果我在路由開始時設置.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
}
Spring 上下文:
<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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.