commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Costin Manolache <>
Subject Re: [CLI] new design possibly?
Date Sun, 09 Feb 2003 20:33:05 GMT
Nicola Ken Barozzi wrote:

>> import org.apache.commons.logging.Log;
>> public class SomeService {
>>     // container sets the logger to be used using IOC
>>     public void setLog(Log log);
>> }
> Is that what packages using Commons Logging do?
> Every single package in Commons that uses CL uses the static accessor.

Commons-logging can be used both ways. Each package can decide
if it wants to use IoC or not. You can choose to not use any
package that is not "pure IoC" - if that's what you want - but
you can't force others to write IoC. 

> What you say is correct, and I would like it to be a possible method to
> enable logging to the component.

Nothing stops you from adding any method you want in components or 
framework or anything else, and nothing forces you to use the inpure
static accessor.

> /**
>   * Components that need to log can implement this interface to
>   * be provided Loggers.
>   *
>   * @author Avalon Development Team
>   */
> public interface LogEnabled
> {
>      /**
>       * Provide component with a logger.
>       *
>       * @param logger the logger. Must not be <code>null</code>.
>       */
>      void enableLogging( Logger logger );
> }

That's wonderfull. You have solved your problem, you have your
interface and you can use it if you like it  - and we can
use the static accessor. 

> Back on track: yes, it can make sense to evaluate Commons Logging as a
> facade for Loggers, but it's a major break in our main code contracts.
> We are discussing about Avalon 5, and Configuration and Logging are a
> major part of that discussion. You are invited  :-)

Thanks, but at least I have found the answers for both logging and
configuration. ( commons-logging API and JMX - plus ant setter patterns 
where JMX is not available ). 

> So let me say the opposite: is Commons Logging advocating IOC?

No. It only advocates a log interface. How you use it is your choice.

> What is the preferred method to get a Logger?
> Come on, be fair. It's the static accessor.

Preffered by most people - yes. I don't think commons-logging itself
has any preferences - it's just a piece of code. 

But again - nothing stops avalon from using a method that is different 
that what other people preffer. 

> We don't want a dependency on a package that has a static accessor to
> get a logger. You may not need it, but why not put this possibility at
> all.

Look - if you can't accept that people want to use a static accessor,
maybe you shouldn't use commons-logging and any of the commons or jakarta
packages that make this choice. 

Nobody forces you or avalon users to use static methods.

>> How did you do that? By writing yet another logging abstraction? :-)
> We had our Logger with a worldful of utility methods for easy logging
> without having to +++ strings together by hand all the time.

Technically - commons-logging doesn't requires you to use Strings.
The param is an Object - it can be a StringBuffer or a String [] or 
any other entity. You'll need some special appenders in log4j ( not 
sure about jdk14 logging ) - but the API is _not_ string based.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message