You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Evans Mark-PT1167 <Ma...@motorola.com> on 2005/02/10 22:32:31 UTC
JMSQueueAppender from contrib (Jamie Tsao)
I'm able to send JMS messages to a JMS Queue using the JMSQueueAppender *only* when I configure it programmatically. It hangs on the queueConnectionFactory.createQueueConnection() when configured with either the PropertyConfigurator or the DOMConfigurator. Any ideas?
Thanks,
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
JMSQueueAppender from contrib (Jamie Tsao)
Posted by Tony <fr...@yahoo.com>.
I'm able to send JMS messages to a JMS Queue using the JMSQueueAppender
*only* when I configure it programmatically.
can someone tell me please how to uae it with an xml file.
I defined log4jconfig.xml and put it in web-inf folder and it wan't working.
any help will be appreciated. thanks.
----- the servlet that uses the JMSQueueAppender ----------
--- when I set up the parameters in the init() method it works fine, but not
with the xml file ----------
import java.io.IOException;
import java.io.PrintWriter;
import javax.naming.Context;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
//import org.apache.log4j.PatternLayout;
public class WebJmsTestServlet extends HttpServlet {
private static final long serialVersionUID = 0L;
static Logger logger = Logger.getLogger
("WebJmsTestServlet.class.getName()");
public WebJmsTestServlet()
{
super();
}
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
logger.setLevel((Level) Level.DEBUG);
logger.info(Context.INITIAL_CONTEXT_FACTORY);
logger.info(Context.PROVIDER_URL);
out.print("<b> All logs were writen</b><br>");
out.print("<b> Into the Queue</b><br>");
out.println("</BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doGet(request, response);
}
/*itialise the appender
public void init()
{
PatternLayout myLayout = new PatternLayout("%d{ISO8601} [%t] %-
5p %c %x - %m%n");
ConsoleAppender consoleAppender = new ConsoleAppender
(myLayout);
JMSQueueAppender jmsQueueAppender = new JMSQueueAppender();
jmsQueueAppender.setInitialContextFactory
("org.jnp.interfaces.NamingContextFactory");
jmsQueueAppender.setProviderUrl("localhost:1099");
jmsQueueAppender.setQueueConnectionFactoryBindingName
("QueueConnectionFactory");
jmsQueueAppender.setQueueBindingName("queue/MyJmsQueue");
jmsQueueAppender.activateOptions();
logger.addAppender(jmsQueueAppender);
logger.addAppender(consoleAppender);
}
*/
}
-------- log4jconfig.xml --------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="A1" class="org.apache.log4j.FileAppender">
<param name="File" value="WebRoot/WEB-INF/logs/SimpleLog.log"/>
<param name="Append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} [%
t] %-5p %c %x - %m%n" />
</layout>
</appender>
<appender name="JMS" class="logging.JMSQueueAppender">
<param name="initialContextFactory"
value="org.jnp.interfaces.NamingContextFactory"/>
<param name="providerUrl" value="localhost:1099"/>
<param name="queueConnectionFactoryBindingName"
value="QueueConnectionFactory"/>
<param name="queueBindingName" value="queue/MyJmsQueue"/>
</appender>
<root>
<level value="debug"/>
<appender-ref ref="A1"/>
<appender-ref ref="JMS"/>
</root>
</log4j:configuration>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
RE: JMSQueueAppender from contrib (Jamie Tsao)
Posted by Donald Larmee <dl...@alterthought.com>.
Can you provide the log4j.properties/log4j.xml file you are using?
-----Original Message-----
From: Evans Mark-PT1167 [mailto:Mark.Evans@motorola.com]
Sent: Thursday, February 10, 2005 4:33 PM
To: 'Log4j Users List'
Subject: JMSQueueAppender from contrib (Jamie Tsao)
I'm able to send JMS messages to a JMS Queue using the JMSQueueAppender
*only* when I configure it programmatically. It hangs on the
queueConnectionFactory.createQueueConnection() when configured with either
the PropertyConfigurator or the DOMConfigurator. Any ideas?
Thanks,
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org