You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Jesse Vitrone <je...@yahoo.com> on 2006/09/19 20:52:00 UTC

settings log4j settings programmatically

The application I work on currently uses Log4j, we at startup, we do this:

* read in xml file with log4j settings (similar to log4j.properties, but this xml has environment dependant settings).
* use our framework to parse the XML and return a Properties object with the right settings for that environment.
* call PropertyConfigurator.configure(props);

I'm trying to use Axis 1.4, which uses Commons Logging and I'm trying turn on debugging for org.apache.axis.transport.http.HTTPSender.  I'm not seeing the Axis logging when I add org.apache.axis.transport.http.HTTPSender into our config file.  

I believe I'm having trouble because we are manually configuring Log4j, and Commons Logging isn't finding a log4j.properties file (since we don't use one).  Is there a way to programmatically configure Commons Logging so that when Axis uses Commons Logging which uses Log4j, it gets our config?

Thanks in advance.






---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: settings log4j settings programmatically

Posted by Jörg Schaible <jo...@gmx.de>.
Hi Jesse,

Jesse Vitrone wrote:

> The application I work on currently uses Log4j, we at startup, we do this:
> 
> * read in xml file with log4j settings (similar to log4j.properties, but
> this xml has environment dependant settings). * use our framework to parse
> the XML and return a Properties object with the right settings for that
> environment. * call PropertyConfigurator.configure(props);
> 
> I'm trying to use Axis 1.4, which uses Commons Logging and I'm trying turn
> on debugging for org.apache.axis.transport.http.HTTPSender.  I'm not
> seeing the Axis logging when I add
> org.apache.axis.transport.http.HTTPSender into our config file.
> 
> I believe I'm having trouble because we are manually configuring Log4j,
> and Commons Logging isn't finding a log4j.properties file (since we don't
> use one).  Is there a way to programmatically configure Commons Logging so
> that when Axis uses Commons Logging which uses Log4j, it gets our config?
> 
> Thanks in advance.

Just write a wrapper for your framework. Implement o.a.c.l.Log that
delegates to your loggers and configure this as the logger implementation
to use: http://jakarta.apache.org/commons/logging/guide.html#Configuration

With LogFactory.releaseAll you might even "reinitialize" the JCL.

- Jörg



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: settings log4j settings programmatically

Posted by Dennis Lundberg <de...@apache.org>.
Jesse Vitrone wrote:
> Well, I guess the issue is that when we use log4j, we manually configure it, but when Commons uses log4j, it hasn't been manually configured by us, so I was wondering if there was a way for Commons Logging to pass our manual configs on to Log4j when Commons initializes it.

No, I'm afraid not. Commons logging has its own configuration, but it 
does not try to pass any configuration on to the underlying logging 
implementation (log4j in your case).

> I'm going to look into the wrapper like Jörg suggested.  Any other ideas?

Jörg's idea is the way to go if you want to make changes in commons 
logging. But I still think it would be a better solution to make your 
current configuration reader/handler work seamlessly with log4j. If you 
can manage that then commons logging will just work.

-- 
Dennis Lundberg

> Thanks.
> 
> 
> ----- Original Message ----
> From: Dennis Lundberg <de...@apache.org>
> To: Jakarta Commons Users List <co...@jakarta.apache.org>
> Sent: Tuesday, September 19, 2006 4:15:41 PM
> Subject: Re: settings log4j settings programmatically
> 
> Jesse Vitrone wrote:
>> The application I work on currently uses Log4j, we at startup, we do this:
>>
>> * read in xml file with log4j settings (similar to log4j.properties, but this xml has environment dependant settings).
>> * use our framework to parse the XML and return a Properties object with the right settings for that environment.
>> * call PropertyConfigurator.configure(props);
>>
>> I'm trying to use Axis 1.4, which uses Commons Logging and I'm trying turn on debugging for org.apache.axis.transport.http.HTTPSender.  I'm not seeing the Axis logging when I add org.apache.axis.transport.http.HTTPSender into our config file.  
>>
>> I believe I'm having trouble because we are manually configuring Log4j, and Commons Logging isn't finding a log4j.properties file (since we don't use one).  Is there a way to programmatically configure Commons Logging so that when Axis uses Commons Logging which uses Log4j, it gets our config?
>>
>> Thanks in advance.
> 
> Commons logging does not try to find configuration files for log4j. That 
> job is left to log4j to do. So I guess asking on one of the mailing 
> lists for logging.apache.org would give you better results.
> 
>  From what I can tell by your description the question you want to ask 
> them is "How can we make a custom configuration handler for log4j?"
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: settings log4j settings programmatically

Posted by Jesse Vitrone <je...@yahoo.com>.
Well, I guess the issue is that when we use log4j, we manually configure it, but when Commons uses log4j, it hasn't been manually configured by us, so I was wondering if there was a way for Commons Logging to pass our manual configs on to Log4j when Commons initializes it.

I'm going to look into the wrapper like Jörg suggested.  Any other ideas?

Thanks.


----- Original Message ----
From: Dennis Lundberg <de...@apache.org>
To: Jakarta Commons Users List <co...@jakarta.apache.org>
Sent: Tuesday, September 19, 2006 4:15:41 PM
Subject: Re: settings log4j settings programmatically

Jesse Vitrone wrote:
> The application I work on currently uses Log4j, we at startup, we do this:
> 
> * read in xml file with log4j settings (similar to log4j.properties, but this xml has environment dependant settings).
> * use our framework to parse the XML and return a Properties object with the right settings for that environment.
> * call PropertyConfigurator.configure(props);
> 
> I'm trying to use Axis 1.4, which uses Commons Logging and I'm trying turn on debugging for org.apache.axis.transport.http.HTTPSender.  I'm not seeing the Axis logging when I add org.apache.axis.transport.http.HTTPSender into our config file.  
> 
> I believe I'm having trouble because we are manually configuring Log4j, and Commons Logging isn't finding a log4j.properties file (since we don't use one).  Is there a way to programmatically configure Commons Logging so that when Axis uses Commons Logging which uses Log4j, it gets our config?
> 
> Thanks in advance.

Commons logging does not try to find configuration files for log4j. That 
job is left to log4j to do. So I guess asking on one of the mailing 
lists for logging.apache.org would give you better results.

 From what I can tell by your description the question you want to ask 
them is "How can we make a custom configuration handler for log4j?"

-- 
Dennis Lundberg

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: settings log4j settings programmatically

Posted by Dennis Lundberg <de...@apache.org>.
Jesse Vitrone wrote:
> The application I work on currently uses Log4j, we at startup, we do this:
> 
> * read in xml file with log4j settings (similar to log4j.properties, but this xml has environment dependant settings).
> * use our framework to parse the XML and return a Properties object with the right settings for that environment.
> * call PropertyConfigurator.configure(props);
> 
> I'm trying to use Axis 1.4, which uses Commons Logging and I'm trying turn on debugging for org.apache.axis.transport.http.HTTPSender.  I'm not seeing the Axis logging when I add org.apache.axis.transport.http.HTTPSender into our config file.  
> 
> I believe I'm having trouble because we are manually configuring Log4j, and Commons Logging isn't finding a log4j.properties file (since we don't use one).  Is there a way to programmatically configure Commons Logging so that when Axis uses Commons Logging which uses Log4j, it gets our config?
> 
> Thanks in advance.

Commons logging does not try to find configuration files for log4j. That 
job is left to log4j to do. So I guess asking on one of the mailing 
lists for logging.apache.org would give you better results.

 From what I can tell by your description the question you want to ask 
them is "How can we make a custom configuration handler for log4j?"

-- 
Dennis Lundberg

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org