[英]log4j not writing logs
Below is my log4j configuration 下面是我的log4j配置
#log4j.additivity.org.apache.qpid=false log4j.rootLogger=DEBUG, console log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.threshold=DEBUG log4j.appender.console.layout.ConversionPattern=%-7p %d [%t] %c %x - %m%n log4j.logger.javax.jms=DEBUG log4j.logger.org.apache.qpid=DEBUG log4j.logger.org.apache.qpid.amqp_1_0=DEBUG log4j.logger.org.apache.qpid.amqp_1_0.jms=DEBUG
and then in code 然后在代码中
String log4jConfigFile = System.getProperty("user.dir") + File.separator + "log4j.properties";
PropertyConfigurator.configure(log4jConfigFile);
logger.debug("this is a debug log message");
my debug message this is a debug log message
do get printed but the log messages from org.apache.qpid
are not getting printed on console 我的调试消息
this is a debug log message
但不会打印,但是org.apache.qpid
的日志消息未在控制台上打印
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-amqp-1-0-client-jms</artifactId>
<version>0.22</version>
</dependency>
EDIT I am a newbie in java... The logging dependencies I have added. 编辑我是Java的新手...已添加日志记录依赖项。 Do I need add some setting somewhere to redirect sl4j logs to log4j??
我是否需要在某处添加一些设置以将sl4j日志重定向到log4j?
<slf4j-version>1.6.6</slf4j-version>
<log4j-version>1.2.17</log4j-version>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j-version}</version>
</dependency>
The (deprecated) qpid-amqp-1-0-client-jms
client used java.util.logging
, and not log4j. (不推荐使用的)
qpid-amqp-1-0-client-jms
客户端使用java.util.logging
,而不是log4j。 To quote from a mail I sent back in 2014 to the users@qpid.apache.org mailing list: 从引用的邮件我送回在2014年到users@qpid.apache.org邮件列表:
you can turn it on by setting the Java system property
java.util.logging.config.file
to point to a file that looks something like this:您可以通过将Java系统属性
java.util.logging.config.file
设置为指向看起来像这样的文件来打开它:handlers=java.util.logging.FileHandler FRM.level=ALL java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter java.util.logging.SimpleFormatter.format=[%1$tc] %4$s: %5$s%n java.util.logging.FileHandler.level=ALL` # (The output file is placed in the directory # defined by the "user.home" System property.) java.util.logging.FileHandler.pattern=%h/qpid-jms-%u.log`
When you run the client it should then generate a file called qpid-jms-0.log in your home directory, with output that looks something like:
运行客户端时,它应该在主目录中生成一个名为qpid-jms-0.log的文件,其输出类似于:
[Mon Feb 24 18:45:58 CET 2014] FINE: RECV[/127.0.0.1:5672|0] : SaslMechanisms{saslServerMechanisms=[ANONYMOUS]}
Note that the logging in this old client is really very minimal and ideally you should instead migrate your code to the supported Qpid JMS client for AMQP 1.0 https://qpid.apache.org/components/jms/index.html which does use slf4j, but uses different configuration syntax for connections and queues. 请注意,在这个旧客户端中的登录确实非常少,理想情况下,您应该将代码迁移到支持AMQP 1.0的Qpid JMS客户端https://qpid.apache.org/components/jms/index.html ,它确实使用slf4j ,但对连接和队列使用不同的配置语法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.