我试图运行这个例子 ,但我有一些问题与配置。
我复制log4j-jms.properties
, jndi.properties
, Log4jJMSAppenderExample.java
ProjectJMS
|
\_ src
| \_ Log4jJMSAppenderExample.java
| \_ jndi.propeties
\_ log4j-jms.properties
并运行activemq
在我的控制台。
当我跑我的例子中,我得到了
log4j:WARN No appenders could be found for logger (org.apache.activemq.transport.WireFormatNegotiator).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.`PropertyConfigurator.configure("log4j-jms.properties");`
所以我加了
PropertyConfigurator.configure("log4j-jms.properties");
现在我可以看到在Eclipse控制台日志,但仍与此警告
log4j:WARN No appenders could be found for logger (org.apache.activemq.transport.WireFormatNegotiator).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2012-08-13 10:21:44,741 INFO Log4jJMSAppenderExample - Test log
Received log [INFO]: Test log
并与控制台activemq
我
WARN | Transport Connection to: tcp://127.0.0.1:2005 failed: java.net.SocketException: Connection reset
为什么会出现这些警告?
是我错了进口?
import javax.jms.Connection; import javax.jms.Message; import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.command.ActiveMQObjectMessage; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; import org.apache.log4j.spi.LoggingEvent;
是我的错地方的文件?
如何设置配置文件在Eclipse? 如果不使用
PropertyConfigurator.configure("log4j-jms.properties");
? 还有比如我按照这样都不行。