D
Duane Morin
Anybody got sample code for sending log4j messages specifically to OpenJMS?
In particular I'd like to do it all programmatically, since I'm working with a fairly complex pre-existing build system and would rather not start introducing too many new properties files. I have a log4j.properties file, but I'm trying to avoid having to create a jndi.properties file.
I stuck this code from OpenJMS in my Logging utility (which wraps log4j):
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.exolab.jms.jndi.InitialContextFactory");
properties.put(Context.PROVIDER_URL, "rmi://localhost:1099/");
Context context = new InitialContext(properties);
and log4j.properties has a simple:
log4j.myLogger=DEBUG, JMS1
log4j.appender.JMS1=org.apache.log4j.net.JMSAppender
log4j.appender.JMS1.TopicBindingName=testtopic
log4j.appender.JMS1.TopicConnectionFactoryBindingName=JmsTopicConnectionFactory
I keep getting the error "javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial" which leads me to believe that my block of code is not storing the InitialContext in a way so that log4j can get at it.
Thanks!
In particular I'd like to do it all programmatically, since I'm working with a fairly complex pre-existing build system and would rather not start introducing too many new properties files. I have a log4j.properties file, but I'm trying to avoid having to create a jndi.properties file.
I stuck this code from OpenJMS in my Logging utility (which wraps log4j):
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.exolab.jms.jndi.InitialContextFactory");
properties.put(Context.PROVIDER_URL, "rmi://localhost:1099/");
Context context = new InitialContext(properties);
and log4j.properties has a simple:
log4j.myLogger=DEBUG, JMS1
log4j.appender.JMS1=org.apache.log4j.net.JMSAppender
log4j.appender.JMS1.TopicBindingName=testtopic
log4j.appender.JMS1.TopicConnectionFactoryBindingName=JmsTopicConnectionFactory
I keep getting the error "javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial" which leads me to believe that my block of code is not storing the InitialContext in a way so that log4j can get at it.
Thanks!