[ 
https://issues.apache.org/jira/browse/LOG4J2-126?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Szabolcs Beki closed LOG4J2-126.
--------------------------------


Thanks. Now, it works as I imagined.

                
> Failover appender doesn't fail over on JMS Queue appender error
> ---------------------------------------------------------------
>
>                 Key: LOG4J2-126
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-126
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 2.0-beta4
>            Reporter: Szabolcs Beki
>            Assignee: Ralph Goers
>             Fix For: 2.0-beta4
>
>
> My goal is to send log messages via a JMS Queue unless the message broker is 
> down, when I simple want send the logs to the Console.
> I configured a failover appender for this purpose:
>  : 
> <appenders>
> ...
>               <JMSQueue name="LiffLog4j2Queue" queueBindingName="Log4j2Queue" 
> factoryBindingName="QueueConnectionFactory"/>
>               <Failover name="FailoverLiffLog4j2Queue" 
> primary="LiffLog4j2Queue" suppressExceptions="false">
>                       <Failovers>
>                               <appender-ref ref="Console"/>
>                       </Failovers>
>               </Failover>
>       </appenders>
>       <loggers>
>               <root level="debug">
>                       <appender-ref ref="FailoverLiffLog4j2Queue"/>           
>               </root>
> All works as expected when the message broker is up. 
> When I shut down the message broker while running my application, instead of 
> the log message  I get this message to my console :
> 2012-11-21 21:51:15,726 ERROR Could not publish message via JMS 
> JMSQueue:QueueConnectionFactory.Log4j2Queue 
> Using a failover appender I expected to get the log messages on the console.
> Also tried to start my application without ever starting message broker. In 
> this case it correctly fails to connect : 
> 2012-11-21 22:10:08,315 DEBUG Calling createAppender on class 
> org.apache.logging.log4j.core.appender.JMSQueueAppender for element JMSQueue 
> with params(name="LiffLog4j2Queue", factoryName="null", providerURL="null", 
> urlPkgPrefixes="null", securityPrincipalName="null", 
> securityCredentials="null", factoryBindingName="QueueConnectionFactory", 
> queueBindingName="Log4j2Queue", userName="null", password="null", null, null, 
> suppressExceptions="null")
> 2012-11-21 22:10:10,167 ERROR Unable to establish connection 
> javax.jms.JMSException: Could not connect to broker URL: 
> tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused: 
> connect
>       at 
> org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)
>       at 
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:293)
>       at 
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:238)
>       at 
> org.apache.activemq.ActiveMQConnectionFactory.createQueueConnection(ActiveMQConnectionFactory.java:199)
>       at 
> org.apache.logging.log4j.core.net.JMSQueueManager$JMSQueueManagerFactory.createManager(JMSQueueManager.java:152)
>       at 
> org.apache.logging.log4j.core.net.JMSQueueManager$JMSQueueManagerFactory.createManager(JMSQueueManager.java:141)
>       at 
> org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:68)
>       at 
> org.apache.logging.log4j.core.net.JMSQueueManager.getJMSQueueManager(JMSQueueManager.java:86)
>       at 
> org.apache.logging.log4j.core.appender.JMSQueueAppender.createAppender(JMSQueueAppender.java:94)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.apache.logging.log4j.core.config.BaseConfiguration.createPluginObject(BaseConfiguration.java:711)
>       at 
> org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:477)
>       at 
> org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:469)
>       at 
> org.apache.logging.log4j.core.config.BaseConfiguration.doConfigure(BaseConfiguration.java:156)
>       at 
> org.apache.logging.log4j.core.config.BaseConfiguration.start(BaseConfiguration.java:114)
>       at 
> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:251)
>       at 
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:267)
>       at 
> org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:134)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:30)
>       at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:165)
>       at com.szabi.experiment.gui.Liff.<clinit>(Liff.java:16)
> Caused by: java.net.ConnectException: Connection refused: connect
>       at java.net.PlainSocketImpl.socketConnect(Native Method)
>       at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
>       at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
>       at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
>       at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
>       at java.net.Socket.connect(Socket.java:529)
>       at 
> org.apache.activemq.transport.tcp.TcpTransport.connect(TcpTransport.java:504)
>       at 
> org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:467)
>       at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:55)
>       at 
> org.apache.activemq.transport.AbstractInactivityMonitor.start(AbstractInactivityMonitor.java:132)
>       at 
> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58)
>       at 
> org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:72)
>       at 
> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58)
>       at 
> org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:58)
>       at 
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:273)
>       ... 23 more
> 2012-11-21 22:10:10,177 ERROR Unable to invoke method createAppender in class 
> org.apache.logging.log4j.core.appender.JMSQueueAppender for element JMSQueue 
> java.lang.reflect.InvocationTargetException
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.apache.logging.log4j.core.config.BaseConfiguration.createPluginObject(BaseConfiguration.java:711)
>       at 
> org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:477)
>       at 
> org.apache.logging.log4j.core.config.BaseConfiguration.createConfiguration(BaseConfiguration.java:469)
>       at 
> org.apache.logging.log4j.core.config.BaseConfiguration.doConfigure(BaseConfiguration.java:156)
>       at 
> org.apache.logging.log4j.core.config.BaseConfiguration.start(BaseConfiguration.java:114)
>       at 
> org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:251)
>       at 
> org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:267)
>       at 
> org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:134)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:75)
>       at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:30)
>       at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:165)
>       at com.szabi.experiment.gui.Liff.<clinit>(Liff.java:16)
> Caused by: java.lang.IllegalStateException: Unable to create a manager
>       at 
> org.apache.logging.log4j.core.appender.AbstractManager.getManager(AbstractManager.java:70)
>       at 
> org.apache.logging.log4j.core.net.JMSQueueManager.getJMSQueueManager(JMSQueueManager.java:86)
>       at 
> org.apache.logging.log4j.core.appender.JMSQueueAppender.createAppender(JMSQueueAppender.java:94)
>       ... 16 more
> BUT shortly afterwards my application exits with : 
> 2012-11-21 22:10:10,238 ERROR Unable to locate primary Appender 
> LiffLog4j2Queue
> 2012-11-21 22:10:10,239 DEBUG Reconfiguration completed
> 2012-11-21 22:10:10,277 ERROR Attempted to append to non-started appender 
> FailoverLiffLog4j2Queue
> 2012-11-21 22:10:10,288 ERROR Attempted to append to non-started appender 
> FailoverLiffLog4j2Queue
> 2012-11-21 22:10:10,292 DEBUG Shutting down FileManager output/experiment.log
> Exception in thread "main" 
> org.apache.logging.log4j.core.appender.AppenderRuntimeException: Attempted to 
> append to non-started appender FailoverLiffLog4j2Queue
>       at 
> org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:88)
>       at 
> org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:335)
> As it can not find primary appender (JMSQueue) it can not start the failover 
> appender either.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to