Log4j JMS附加程序示例 [英] Log4j JMS appender example

查看:230
本文介绍了Log4j JMS附加程序示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试遵循此示例,但是当我将此类复制到项目中时,我无法运行它.

I tried to follow this example, but when I copied this class to my project I failed to run it.

我不知道导入的样子,因为eclipse提供了很多选择.我尝试过

I've no idea how my imports should look like, because eclipse suggests a lot of options. I tried

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.spi.LoggingEvent;

但是我得到了

log4j:WARN No appenders could be found for logger (org.apache.activemq.transport.tcp.TcpTransport).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

该教程对我来说还不清楚.您是否了解更多详细信息(绝对入门)?也许您知道如何解决这种例外情况?

This tutorial isn't clear for me. Do you know anything with more details (to absolute begginer)? Or maybe you know how to solve my problem with this exception?

log4.properties是示例中文件的精确副本

log4.properties is exact copy of file in example

log4j.rootLogger=INFO, stdout, jms

## Be sure that ActiveMQ messages are not logged to 'jms' appender
log4j.logger.org.apache.activemq=INFO, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %-5p %c - %m%n

## 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

推荐答案

我认为您在配置log4j.properties文件时遇到问题.仔细看一下它的配置.您可以尝试通过Google查找有关配置log4j的教程,例如,外观

I think you have problem in you configuration log4j.properties file. Look carefuly to it configuration. You can try to find tutorials about configuration log4j with google for example look this

这篇关于Log4j JMS附加程序示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆