Mark,

Thank you very much for this extensive patch. You have filled in many
of the omissions -- some intentional -- of this part of the API.

Setting a default logger factory causes no trouble as long as only one
pplication -- under the control of one development team -- uses custom
log4j loggers. However, if another developer also decides to set the
logger factory, then the structure cracks and comes tumbling down.

Thus, as much as I would like to favor user extensions, I do not think
it is wise to invest in this part of the log4j API containing serious
structural weaknesses without first correcting those weaknesses.

One way to "safely" set the logger factory is restrict the parts of
the logger hierarchy to which the factory applies. So, one users can
set the factory X for loggers under "com.foo" and another user can set
it to Y for loggers under "org.bar". See what I am getting at?

At 12:20 PM 9/1/2003 -0400, Mark Priest wrote:
Hi,

I am interested in using my own custom LoggerFactory and I have been unable
to do so because of a bug that has been reported as 21707
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21707) and 13099
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13099).  I have prepared
a fix for this bug that is attached.  I have included both new source files
as well as diffs against the Aug 31, 2003 version of the affected files from
CVS.  Please consider adding this change to the current version of log4j in
CVS.

Here is a summary of the changes I made:

******
org.apache.log4j.spi.LoggerRepository.java

- added a new method
public void setDefaultLoggerFactory(LoggerFactory factory);

This method allows a Configurator to set the default LoggerFactory

****
org.apache.log4j.xml.DOMConfigurator.java

- modified to parse the loggerFactory tag and set the new default
LoggerFactory on the repository

****
org.apache.log4j.xml.log4j.dtd

- changed the "categoryFactory" tag to "loggerFactory" and moved it before
the category and logger tags so that the correct default LoggerFactory will
be used to create those categories and loggers.

******
org.apache.log4j.Hierarchy.java

- added impl for new setDefaultLoggerFactory method

******
org.apache.log4j.PropertyConfigurator.java

- modified the LoggerFactory configuration code to set the default
LoggerFactory on the LoggerRepository

*******
examples.subclass.MyLogger.java

- modified to use only the factory mechanism and not require use of
MyLogger.getCategory

*******
examples.subclass.MyLoggerTest.java

- modified the test to use only the factory mechanism and not require the
explicit use of MyLogger

********
examples.subclass.myloggerconfig.xml

- a config file that shows how to use the loggerFactory tag

********
examples.subclass.log4j.dtd

- copied the dtd so the config file can be parsed

Thanks,
Mark

-- Ceki Gülcü

     For log4j documentation consider "The complete log4j manual"
     ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp

     See you in November at ApacheCon US 2003 in Las Vegas.
     http://apachecon.com/



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to