You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Simon Kitching <sk...@apache.org> on 2005/05/23 01:24:01 UTC

[logging] detecting logging libs

On Sun, 2005-05-22 at 21:01 +0100, robert burrell donkin wrote:
> On Sun, 2005-05-22 at 10:43 +0000, skitching@apache.org wrote:
> 
> <snip>
> 
> >      protected boolean isJdk13LumberjackAvailable() {
> >  
> > +        // note: the algorithm here is different from isLog4JAvailable.
> > +        // I think isLog4JAvailable is correct....see bugzilla#31597
> 
> +1
> 
> could do with going through all the isAvailable's and checking whether
> their algorithms are correct. however, i suspect that brian's approach
> will be needed to deal correctly with some circumstances. if no one
> feels like volunteering should probably record this in bugzilla so we
> don't lose track...

If by "brian's approach" you mean creating an instance of the logger
class in order to test whether that logging lib is *really* available, I
agree. 

Not only is it more reliable, but it's a cleaner solution; currently the
LogFactoryImpl class is making *assumptions* about what classes the
various logging adapters depend on. That information should be only in
the logging adapter class.

The only problem with creating an instance of the logger is that we
would have to pass a category string to the logger constructor, and
therefore must build an assumption into LogFactoryImpl about what
category names are valid for the underlying logger. Can we assume that
an empty string is a valid category for all logger libraries? Can we
assume that "apache" or "org.apache.commons.logging" are valid category
strings? Perhaps some loggers only accept valid URLs as
categories...yes, I'm playing devil's advocate a bit here. I guess we
could always say that the writer of the logging adapter is required to
return a valid logger instance for category "", even if that is not
normally a category that is valid to the underlying library.

Regards,

Simon



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


Re: [logging] detecting logging libs

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Mon, 2005-05-23 at 11:24 +1200, Simon Kitching wrote:
> On Sun, 2005-05-22 at 21:01 +0100, robert burrell donkin wrote:
> > On Sun, 2005-05-22 at 10:43 +0000, skitching@apache.org wrote:
> > 
> > <snip>
> > 
> > >      protected boolean isJdk13LumberjackAvailable() {
> > >  
> > > +        // note: the algorithm here is different from isLog4JAvailable.
> > > +        // I think isLog4JAvailable is correct....see bugzilla#31597
> > 
> > +1
> > 
> > could do with going through all the isAvailable's and checking whether
> > their algorithms are correct. however, i suspect that brian's approach
> > will be needed to deal correctly with some circumstances. if no one
> > feels like volunteering should probably record this in bugzilla so we
> > don't lose track...
> 
> If by "brian's approach" you mean creating an instance of the logger
> class in order to test whether that logging lib is *really* available, I
> agree.

yes 

(hopefully brian will jump in here and correct any misunderstandings) 

> Not only is it more reliable, but it's a cleaner solution; currently the
> LogFactoryImpl class is making *assumptions* about what classes the
> various logging adapters depend on. That information should be only in
> the logging adapter class.

+1

in addition, the specification allows variation as to the timing of
error reporting. i believe that creating an instances would give more
consistency across JVMs.

> The only problem with creating an instance of the logger is that we
> would have to pass a category string to the logger constructor, and
> therefore must build an assumption into LogFactoryImpl about what
> category names are valid for the underlying logger. Can we assume that
> an empty string is a valid category for all logger libraries? Can we
> assume that "apache" or "org.apache.commons.logging" are valid category
> strings? Perhaps some loggers only accept valid URLs as
> categories...yes, I'm playing devil's advocate a bit here. I guess we
> could always say that the writer of the logging adapter is required to
> return a valid logger instance for category "", even if that is not
> normally a category that is valid to the underlying library.

IIRC brian's patch refactored the code so that the test also constructed
the correct logger instance (or something like that). if you don't beat
me to it, i'll commit the patch onto one of the branches so that
everyone can easily take a look at the approach. 

(again hopefully brian will jump in here if i've made any mistakes)

- robert


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