Summary: | Requirement: Combine JCL and UGLI | ||
---|---|---|---|
Product: | Log4j - Now in Jira | Reporter: | Boris Unckel <boris.unckel.mlg> |
Component: | Other | Assignee: | log4j-dev <log4j-dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | commons-dev |
Priority: | P5 | Keywords: | PatchAvailable |
Version: | 1.3alpha | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Attachments: | UgliFactory extends org.apache.commons.logging.LogFactory.LogFactory |
Description
Boris Unckel
2005-03-25 22:06:27 UTC
I dislike the word "requirement" in a Bugzilla issue ;( FWIW issues like this have been discussed at length on the jakarta commons list. I thought it might save a little time if I were to point out the tricky bit of any JCL redesign. The key design mistake made when JCL was created was not the much-malined dynamic discovery mechanism, it was the fact that LogFactory is too tightly coupled to the discovery mechanism. It would be possible to extract an interface modelled as an abstract superclass containing the user-facing API from LogFactory and retrofit a minimal implementation lookup mechanism with no complex discovery. This would allow refitting of new binding mechanisms whilst maintaining backwards compatibility. Had the storm not blown up about the current JCL implementation, this was the direction which the JCL2 codebase would have taken. Hmmm.... I mentioned something very similar, only exactly opposite, in my email response to Simon Kitching. This... public interface ULogger extends org.apache.commons.logging.Log Becomes this... public interface org.apache.commons.logging.Log extends ULogger It doesn't make sense for a logging implementation which commons-logging wraps, such as Log4j, to have a dependency on commons-logging itself, which it would by its implementation of UGLI. Having commons-logging implement UGLI (or whatever name it ends up as) also solves an issue with coordination of projects. Simon Kitching mentioned that it will be 2 or 3 months before JCL 2.0 becomes more than an idea. UGLI exists now, Log4j implements it, and Log4j-1.3 is tentatively scheduled to be released around the time where JCL 2.0 will be just getting off the ground. The JCL team also has requirements such as backward compatibility and the extension of their own API with new functionality. If we can all agree on a base logging API, then everyone can simply agree to implement it and take as much time as they want. Existing API's shouldn't have to change much (if at all) and extention of the API's can be done at will. A change like this would allow commons-logging users the option to either continue to use the JCL API or move to the UGLI API. In the case where they choose the UGLI API, they can choose any implementation that implements the UGLI API, including Log4j, JCL, NOP, Simple, and even choose an UGLI wrapper such as the UGLI JUL wrapper implementation. All API's become compatible and users can choose which implementation of UGLI meets their needs the best. I don't think anyone loses here. UGLI can stay "UGLI" or become something like "Apache Logging API, or "ALAPI". Whatever name is chosen, the point is that its interface becomes the standard for everyone. Thoughts? Jake (In reply to comment #3) > I mentioned something very similar, only exactly opposite, in my email response > to Simon Kitching. Yes, I have read that mail. > This... > public interface ULogger extends org.apache.commons.logging.Log > > Becomes this... > public interface org.apache.commons.logging.Log extends ULogger > > > It doesn't make sense for a logging implementation which commons-logging wraps, > such as Log4j, to have a dependency on commons-logging itself, which it would by > its implementation of UGLI. I think one has to small steps, even for getting acceptance. UGLI is out as alpha. UGLI (or better log4j 1.3) introduce multiple jars (I know that solves problems and is a good idea, but for users this is a eye-catching change), and users have to code different to use it. I think it should be no problem to package the interface (not the whole JCL) with log4j. For me UGLI is an wrapper, and it will be wide spread due to the popularity of log4j. Once introduced it will be hard to change. To have an interim solution JCL's Factory could be changed to the static binding and an configuration only (without classloading isues) lookup. >Having commons-logging implement UGLI (or whatever > name it ends up as) also solves an issue with coordination of projects. Sounds not like a win-win to me. > Simon > Kitching mentioned that it will be 2 or 3 months before JCL 2.0 becomes more > than an idea. What kind of feature should JCL 2.0 offer, if it is done like you described? Just my first impression, I still want to disuss factually: JCL==YAUGLI, yet another... > UGLI exists now, Log4j implements it, and Log4j-1.3 is JCL exists now, Wrappers are existing, major applications use it. > tentatively scheduled to be released around the time where JCL 2.0 will be just > getting off the ground. Yes, correct, so we there is a need to get ideas to solve this time gap. > The JCL team also has requirements such as backward > compatibility and the extension of their own API with new functionality. UGLI has no backward compatibility issues and contains new functionality. > If we > can all agree on a base logging API, then everyone can simply agree to implement > it and take as much time as they want. Existing API's shouldn't have to change > much (if at all) and extention of the API's can be done at will. > A change like this would allow commons-logging users the option to either Sorry, maybe I am not wide awake - what is "this"? Your proposal or the demo code? > continue to use the JCL API or move to the UGLI API. In the case where they > choose the UGLI API, they can choose any implementation that implements the UGLI > API, including Log4j, JCL, NOP, Simple, and even choose an UGLI wrapper such as > the UGLI JUL wrapper implementation. The idea of wrapping and having the choice is the major goal of JCL and main succesing feature. The demo code should just show how less change in UGLI is necessary to become an integration of JCL. Next changes have to be done in JCL. Boris Created attachment 14568 [details]
UgliFactory extends org.apache.commons.logging.LogFactory.LogFactory
This factory whould implement a backward compatible version of the JCL
LogFactory.
If one is convinced this could be the default Factory for JCL. All
configuration issues would occur at Ugli. This also could be a migration path.
It depends on ULogger extends org.apache.commons.logging.Log as published in
this Bugzilla.
Comments?
FWIW I've analysed these issues in depth and believe that subclassing will not prove effective due to the coupling problems I indicated above. A better path would be to extract an abstract superclass as part of JCL and subclass that instead. JCL will probably go down this route in any case. I thought an example would be useful :) So, I've create a branch in jakarta/commons/logging called DON_QUIXOTE and added some example code into their. This lifts off a superclass called LogManager (for no very good reason) from LogFactory. The most common user method (getLog) is rewired so that it first calls the superclass. When LogFactory is in the same classloader (ideally in the same jar) as LogManager, the call will be routed through LogFactory. This preserves backwards compatibility. This is the way that Richard and I saw JCL2 proceeding. An option which you may want to consider is compile-time statically binding an alternative LogManager implementation to UGLI. This (I believe) would in line with the spirit of the UGLI way whilst also ensure no actual core dependencies either way. If anyone feels this sounds like a reasonable approach and would like to take a look at creating some experimental implementation code along those lines, I'd be glad to review it for possible inclusion in the branch. I'm don't intend to particularly push this solution (UGLI is the responsibility of others) but I think it's important that all possible solutions are considered. Robert UGLI development has been moved to http://www.slf4j.org. |