On 4/3/02 2:26 PM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> On Wed, 3 Apr 2002, Geir Magnusson Jr. wrote:
>
>>> class MyComponent
>>> implements Component, LogEnabled
>>> {
>>> private static Logger logger = Log.getLogger();
>>>
>>> myMethod()
>>> {
>>> logger.info("Hello World!");
>>> }
>>> }
>>>
>>> Seems so much cleaner of a design to me and it is impossible to get an NPE.
>>
>> Except that forces there to be something called Log in the classpath. In
>> the case where you are using the component/tool in an environment where that
>> doesn't exist, you'll get a different exception, out of your control...
>
> Well, if you implement LogUser you'll still have to have commons-logging
> in the classpath, wouldn't you ?
>
Yes, that's true. I didn't realize that it o.a.c.l was actually a logging
framework.... I thought it was an interface we could write to in order to
isolate ourselves from changing logger preferences...
>
> I'm thinking as:
>
> class MyClass implements LogUser {
> // default logger
> private static Logger logger = Log.getLogger(MyClass.class);
>
> public void setLogger( Log log ) {
> logger=log;
> }
That works too.
> ...
> if( logger.isDebugEnabled() ) logger.debug("Something" );
> }
>
> You start with a normal default, but at runtime the user decides he wants
> a different logger. Of course, this could be done by managing the logging
> implementation itself.
Yep
--
Geir Magnusson Jr. [EMAIL PROTECTED]
System and Software Consulting
Be a giant. Take giant steps. Do giant things...
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>