2016-02-28 32 views
2

下面我將程序發送一條消息,並使用來自隊列中的消息,現在我已經註釋掉髮送方和唯一想消費從隊列中的消息現在在Spring集成utiliy啓用日誌記錄

我想以便能夠在下面的程序日誌,使得日誌文件是在我的C產生:驅動器和日誌文件中應該表明什麼樣的信息是在什麼時間戳記費時,請告知如何以下配置文件中的配置日誌

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:int="http://www.springframework.org/schema/integration" 
    xmlns:jms="http://www.springframework.org/schema/integration/jms" 
    xmlns:file="http://www.springframework.org/schema/integration/file" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 

    http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd 
    http://www.springframework.org/schema/integration/jms 
    http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd 
    http://www.springframework.org/schema/integration/spring-integration.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/integration/file 
    http://www.springframework.org/schema/integration/file/spring-integration-file.xsd  
    http://www.springframework.org/schema/context/spring-context.xsd"> 


    <int:poller id="poller" default="true"> 
     <int:interval-trigger interval="200" /> 
    </int:poller> 



    <int:channel id="input"> 
     <int:queue capacity="10" /> 
    </int:channel> 

    <bean id="tibcoEMSJndiTemplate" class="org.springframework.jndi.JndiTemplate"> 
     <property name="environment"> 
      <props> 
       <prop key="java.naming.factory.initial">com.tibco.tibjms.naming.TibjmsInitialContextFactory 
       </prop> 
       <prop key="java.naming.provider.url">tcp://lsdrtems2.fm.crdgrp.net:7333</prop> 
       <prop key="java.naming.security.principal">acfgtir</prop> 
       <prop key="java.naming.security.credentials">acfgtir</prop> 
      </props> 
     </property> 
    </bean> 

    <bean id="tibcoEMSConnFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> 
     <property name="jndiTemplate"> 
      <ref bean="tibcoEMSJndiTemplate" /> 
     </property> 
     <property name="jndiName"> 
      <value>GenericConnectionFactory</value> 
     </property> 
    </bean> 

    <bean id="tibcosendJMSTemplate" class="org.springframework.jms.core.JmsTemplate"> 
     <property name="connectionFactory"> 
      <ref bean="tibcoEMSConnFactory" /> 
     </property> 
     <property name="defaultDestinationName"> 
      <value>acfgtirrtyation.ioa.swretift_publish_poc1</value> 
     </property> 
     <property name="pubSubDomain"> 
      <value>false</value> 
     </property> 
     <property name="receiveTimeout"> 
      <value>120000</value> 
     </property> 
    </bean> 




    <!-- <jms:outbound-channel-adapter channel="input" 
     destination-name="acfgtirrtyation.ioa.swretift_publish_poc1" connection-factory="tibcoEMSConnFactory" /> --> 

<int:channel id="objetChannel"></int:channel> 
<int:channel id="StringChannel"></int:channel> 
<int:channel id="jmsInChannel" /> 



<jms:message-driven-channel-adapter id="jmsIn" concurrent-consumers="10" 
     destination-name="acfgtirrtyation.ioa.swretift_publish_poc1" connection-factory="tibcoEMSConnFactory" extract-payload="false" 
     channel="jmsInChannel" /> 

    <int:payload-type-router input-channel="jmsInChannel"> 
    <int:mapping type="javax.jms.ObjectMessage" channel="objetChannel" /> 
    <int:mapping type="javax.jms.TextMessage" channel="StringChannel" /> 
    </int:payload-type-router> 



<file:outbound-channel-adapter id="filesoutOject" channel="objetChannel" directory="C:\\abcsaral" 
filename-generator="generatorr" /> 



<file:outbound-channel-adapter id="filesoutString" channel="StringChannel" directory="C:\\abcsaral" 
filename-generator="generatorr" /> 

<bean id="generatorr" class="com.abs.tibco.TimestampTextGenerator"> 
    </bean> 


</beans> 

回答

4

添加log4j的(或的logback,或通過共享記錄支持任何Java記錄系統),以您的classpath中次將其配置爲日誌org.springframework.integration類別調試級別。

或者你也可以到渠道和途徑來增加一個wire tap到記錄通道適配器

<int:channel id="in"> 
    <int:interceptors> 
     <int:wire-tap channel="logger"/> 
    </int:interceptors> 
</int:channel> 

<int:logging-channel-adapter id="logger" level="DEBUG"/> 
+0

IThanks我想引入線自來水只是爲了檢查什麼是通道內發生 – sss

+0

是;你可以做到這一點 - 我編輯的答案在您發佈此評論的同時。 –

+0

謝謝Gary,請您介紹一下日誌記錄通道適配器,如果您可以將它添加到上面的任何一個通道,以便我可以掌握,它會很好。 – sss