我复制了
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
为什么会收到这些警告?
Are my imports wrong?
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;
Are my files in wrong place?
How to set configuration file in Eclipse? Without using
PropertyConfigurator.configure("log4j-jms.properties");
? There is no line like this in example I follow.
-Dlog4j.configuration=log4j-jms.properties
。现在可以工作了,谢谢。 - alicjasalamonlog4j-jms.properties
?你根本不需要它。log4j.properties
是 Log4J 的系统默认配置属性。 - Buhake Sindilog4j-jms.properties
,而没有log4j.properties
。我可以将其重命名,但它仍然可以正常工作。 - alicjasalamon