You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by selezovikj <se...@gmail.com> on 2009/01/29 18:20:55 UTC

log4j - Jndi context addToEnvironment has no effect

I have a JmsQueueAppender that logs messages to an ActiveMQ broker on a given
queue. 
I also have a jndi.properties file in which I do NOT specify the
provider.url value, because that value can vary depending on a flag. 

In my JmsQueueAppender, the jndi context is initialized using the default
no-argument constructor. 


jndi = new InitialContext();
System.out.println(jndi.getEnvironment().toString());

Printing the environment values which are gotten using the default
constructor results with the following values which I have specified in my
jndi.properties file: 
{java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory,
queue.LoggingQueue=LoggingQueue}

Later I add to the environment the provider.url value. 

jndi.addToEnvironment(Context.PROVIDER_URL,
"failover:(tcp://localhost:61617)");
System.out.println(jndi.getEnvironment().toString());

results with: 
{java.naming.provider.url=failover:(tcp://localhost:61617),
java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory,
queue.LoggingQueue=LoggingQueue}

Even though, the provider.url is added to the environment, when logging
log4j does not take into account the provider url I just specified. It
simply does not log to 61617. 

Any help with this ? ? ?
-- 
View this message in context: http://www.nabble.com/log4j---Jndi-context-addToEnvironment-has-no-effect-tp21731483p21731483.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: log4j - Jndi context addToEnvironment has no effect

Posted by James Strachan <ja...@gmail.com>.
Have you tried just configuring whatever properties you need as a
Hashtable and passing them into the InitialContext() constructor?

2009/1/29 selezovikj <se...@gmail.com>:
>
> I have a JmsQueueAppender that logs messages to an ActiveMQ broker on a given
> queue.
> I also have a jndi.properties file in which I do NOT specify the
> provider.url value, because that value can vary depending on a flag.
>
> In my JmsQueueAppender, the jndi context is initialized using the default
> no-argument constructor.
>
>
> jndi = new InitialContext();
> System.out.println(jndi.getEnvironment().toString());
>
> Printing the environment values which are gotten using the default
> constructor results with the following values which I have specified in my
> jndi.properties file:
> {java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory,
> queue.LoggingQueue=LoggingQueue}
>
> Later I add to the environment the provider.url value.
>
> jndi.addToEnvironment(Context.PROVIDER_URL,
> "failover:(tcp://localhost:61617)");
> System.out.println(jndi.getEnvironment().toString());
>
> results with:
> {java.naming.provider.url=failover:(tcp://localhost:61617),
> java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory,
> queue.LoggingQueue=LoggingQueue}
>
> Even though, the provider.url is added to the environment, when logging
> log4j does not take into account the provider url I just specified. It
> simply does not log to 61617.
>
> Any help with this ? ? ?
> --
> View this message in context: http://www.nabble.com/log4j---Jndi-context-addToEnvironment-has-no-effect-tp21731483p21731483.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>



-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: log4j - Jndi context addToEnvironment has no effect

Posted by selezovikj <se...@gmail.com>.
@Joe - I set the PROVIDER_URL immediately after log4j calls the
InitialContext() constructor. 

@James - Will try that first thing in the morning 




Joe Fernandez wrote:
> 
> Are you extending Jamie Tsao's JMSQueueAppender?
> 
> Is your activateOptions() method being called prior to you setting the
> PROVIDER_URL?
> 
> Joe
> Free ActiveMQ user guide @ http://www.ttmsolutions.com
> 
> 
> 
> selezovikj wrote:
>> 
>> I have a JmsQueueAppender that logs messages to an ActiveMQ broker on a
>> given queue. 
>> I also have a jndi.properties file in which I do NOT specify the
>> provider.url value, because that value can vary depending on a flag. 
>> 
>> In my JmsQueueAppender, the jndi context is initialized using the default
>> no-argument constructor. 
>> 
>> 
>> jndi = new InitialContext();
>> System.out.println(jndi.getEnvironment().toString());
>> 
>> Printing the environment values which are gotten using the default
>> constructor results with the following values which I have specified in
>> my jndi.properties file: 
>> {java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory,
>> queue.LoggingQueue=LoggingQueue}
>> 
>> Later I add to the environment the provider.url value. 
>> 
>> jndi.addToEnvironment(Context.PROVIDER_URL,
>> "failover:(tcp://localhost:61617)");
>> System.out.println(jndi.getEnvironment().toString());
>> 
>> results with: 
>> {java.naming.provider.url=failover:(tcp://localhost:61617),
>> java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory,
>> queue.LoggingQueue=LoggingQueue}
>> 
>> Even though, the provider.url is added to the environment, when logging
>> log4j does not take into account the provider url I just specified. It
>> simply does not log to 61617. 
>> 
>> Any help with this ? ? ?
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/log4j---Jndi-context-addToEnvironment-has-no-effect-tp21731483p21732834.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: log4j - Jndi context addToEnvironment has no effect

Posted by Joe Fernandez <jo...@ttmsolutions.com>.
Are you extending Jamie Tsao's JMSQueueAppender?

Is your activateOptions() method being called prior to you setting the
PROVIDER_URL?

Joe
Free ActiveMQ user guide @ http://www.ttmsolutions.com



selezovikj wrote:
> 
> I have a JmsQueueAppender that logs messages to an ActiveMQ broker on a
> given queue. 
> I also have a jndi.properties file in which I do NOT specify the
> provider.url value, because that value can vary depending on a flag. 
> 
> In my JmsQueueAppender, the jndi context is initialized using the default
> no-argument constructor. 
> 
> 
> jndi = new InitialContext();
> System.out.println(jndi.getEnvironment().toString());
> 
> Printing the environment values which are gotten using the default
> constructor results with the following values which I have specified in my
> jndi.properties file: 
> {java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory,
> queue.LoggingQueue=LoggingQueue}
> 
> Later I add to the environment the provider.url value. 
> 
> jndi.addToEnvironment(Context.PROVIDER_URL,
> "failover:(tcp://localhost:61617)");
> System.out.println(jndi.getEnvironment().toString());
> 
> results with: 
> {java.naming.provider.url=failover:(tcp://localhost:61617),
> java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory,
> queue.LoggingQueue=LoggingQueue}
> 
> Even though, the provider.url is added to the environment, when logging
> log4j does not take into account the provider url I just specified. It
> simply does not log to 61617. 
> 
> Any help with this ? ? ?
> 

-- 
View this message in context: http://www.nabble.com/log4j---Jndi-context-addToEnvironment-has-no-effect-tp21731483p21732535.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.