[slf4j-dev] Re: Factory methods

Curt Arnold carnold at houston.rr.com
Wed Aug 10 21:35:00 CEST 2005


On Aug 10, 2005, at 2:08 PM, Ceki Gülcü wrote:

>
>
> It seems to me that the problem solved by javax.xml.parsers is
> significantly different. For example, while it is OK for consecutive
> calls to newInstane method in javax.xml.parsers.SAXParserFactory to
> return distinct SAXParserFactory instances, in the logging world,
> consecutive calls to newLoggerBuilder() in LoggerBuilderFactory should
> return the *same* LoggerBuilder.
>

I kept to the similar method names as the javax.xml.parsers methods  
for illustration purposes, but I was fully aware that the instance  
returned by "newLoggerBuilder" would return the same instance.  As I  
suggested in the potential names, getHierarchy() might be a better name.


> Unless I am missing something, this difference invalidates the  
> approach
> adopted by javax.xml.parsers in the case of logging.
>
> Do you still think that the javax.xml.parsers is applicable? If not,
> any better ideas?


Without a mechanism to get at the LoggerFactory instance, there is no  
mechanism to interrogate the factory for capabilities.  So what I was  
suggesting is that there are static methods on some class to get a  
(likely singleton) instance of a factory implementation that can be  
used to get instances of Logger.  You could still have the short-cut  
methods to go directly from the static method to get an instance of  
Logger, but having the intermediate factory instance is beneficial. 
  


More information about the slf4j-dev mailing list