2014-06-11 59 views
0

我試過使用JMSAppender按照說明找到here。我試圖在ActiveMQ的MuleStudio環境中使用它。JMSAppender - 找不到主題

添加以下到我的log4j.xml文件:

<appender name="jms" class="org.apache.log4j.net.JMSAppender"> 
    <param name="InitialContextFactoryName" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory" /> 
    <param name="ProviderURL" value="tcp://localhost:61616" /> 
    <param name="TopicBindingName" value="logTopic" /> 
    <param name="TopicConnectionFactoryBindingName" value="ConnectionFactory" /> 
</appender> 
<logger name="org.apache.activemq"> 
    <appender-ref ref="console" /> 
</logger> 

我創建的內容在classpath中,jndi.properties文件:

topic.logTopic=logTopic 

我加ActiveMQ的核心 - 5.7 .0.Jar進入MuleStudio的類路徑。

當我嘗試運行Mule應用程序時,我在下面的異常顯示中找不到主題名稱。

我用ActiveMQ的控制檯來手動創建主題,但這並沒有改變任何東西。

我在做什麼錯?

控制檯日誌輸出:

log4j: Class name: [org.apache.log4j.net.JMSAppender] 
log4j: Setting property [initialContextFactoryName] to [org.apache.activemq.jndi.ActiveMQInitialContextFactory]. 
log4j: Setting property [providerURL] to [tcp://localhost:61616]. 
log4j: Setting property [topicBindingName] to [logTopic]. 
log4j: Setting property [topicConnectionFactoryBindingName] to [ConnectionFactory]. 
log4j: Getting initial context. 
log4j: Looking up [ConnectionFactory] 
log4j: About to create TopicConnection. 
log4j: Creating TopicSession, non-transactional, in AUTO_ACKNOWLEDGE mode. 
log4j: Looking up topic name [logTopic]. 
log4j:ERROR Could not find name [logTopic]. 
log4j:ERROR Error while activating options for appender named [jms]. 
javax.naming.NameNotFoundException: logTopic 
    at org.apache.activemq.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:235) 
    at javax.naming.InitialContext.lookup(InitialContext.java:411) 
    at org.apache.log4j.net.JMSAppender.lookup(JMSAppender.java:245) 
    at org.apache.log4j.net.JMSAppender.activateOptions(JMSAppender.java:222) 
    at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307) 
    at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:295) 
    at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:176) 
    at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:191) 
    at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:523) 
    at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:492) 
    at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:1001) 
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:867) 
    at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:773) 
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:483) 
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:127) 
    at org.apache.log4j.Logger.getLogger(Logger.java:117) 
    at org.mule.module.logging.LoggerReferenceHandler.<init>(LoggerReferenceHandler.java:28) 
    at org.mule.module.logging.MuleLogFactory.<init>(MuleLogFactory.java:41) 
    at org.apache.commons.logging.LogFactory.<clinit>(LogFactory.java:32) 
    at org.mule.module.launcher.CompositeDeploymentListener.<init>(CompositeDeploymentListener.java:24) 
    at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:108) 

回答

0

需要做到以下幾點:

  1. mule/conf DIR有topic.logTopic=logTopic
  2. 創建一個jndi.properties文件放在mule/lib/boot以下jar文件: activemq-client-5.8.0.jar, geronimo-j2ee-management_1.1_spec-1.0.1.jar,geronimo-jms_1.1_spec-1.1.1.jar
  3. 以下添加到您的log4j.properties爲服務
 
    # settings for specific packages 
    log4j.logger.org.mule=INFO 
    log4j.logger.com.mule.support=INFO 
    #log4j.logger.org.mule.api.processor.LoggerMessageProcessor=${custom-level} 
    log4j.logger.httpclient.wire.header=DEBUG, jms 

    log4j.logger.org.apache.activemq=INFO, stdout 
    ## Configure 'jms' appender. You'll also need jndi.properties file in order to make it work 
    log4j.appender.jms=org.apache.log4j.net.JMSAppender 
    log4j.appender.jms.InitialContextFactoryName=org.apache.activemq.jndi.ActiveMQInitialContextFactory 
    log4j.appender.jms.ProviderURL=tcp://localhost:61616 
    log4j.appender.jms.TopicBindingName=logTopic 
    log4j.appender.jms.TopicConnectionFactoryBindingName=ConnectionFactory