ceki 01/04/13 23:57:23 Modified: . .cvsignore docs HISTORY src/java/org/apache/log4j BasicConfigurator.java ConsoleAppender.java Hierarchy.java src/java/org/apache/log4j/spi OptionHandler.java src/java/org/apache/log4j/xml/test do1.xml do2.xml do3.xml do4.xml do5.xml do6.xml do7.xml do8.xml do9.xml Added: docs .cvsignore src/java Makefile src/java/org/apache/log4j/examples .cvsignore Log: Added the disable faimily of methods back into the BasicConfigurator to ensure backward compatibility. The methods are marked as deprecated. Cleaned up the src/java/org/apache/log4j/xml/test/do*.xml test files to use the ConsoleAppender instead of the FileAppender. Misc. documentation changes. Revision Changes Path 1.2 +1 -0 jakarta-log4j/.cvsignore Index: .cvsignore =================================================================== RCS file: /home/cvs/jakarta-log4j/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- .cvsignore 2001/04/11 21:38:13 1.1 +++ .cvsignore 2001/04/14 06:57:21 1.2 @@ -1 +1,2 @@ goEnv* +dist \ No newline at end of file 1.30 +9 -8 jakarta-log4j/docs/HISTORY Index: HISTORY =================================================================== RCS file: /home/cvs/jakarta-log4j/docs/HISTORY,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- HISTORY 2001/04/13 00:12:18 1.29 +++ HISTORY 2001/04/14 06:57:21 1.30 @@ -6,7 +6,7 @@ [***] Changes requiring important modifications to existing client code. - March ??, 2001 + April ??, 2001 - Release of version 1.1b2 @@ -31,6 +31,11 @@ - In XML configuration files, the <configuration> element has been deprecated and was replaced by the <log4j:configuration> element. [*] + + The following perl command can help to migrate: + + perl -p -i.bak -e "s/configuration/log4j:configuration/;" file1.xml .. fileN.xml + February 23, 2001 @@ -38,14 +43,10 @@ - Logging can now be disabled per Hierarchy. It can also be disabled using configuration files using the "disable" directive. The - disableOverride directive takes precedence over the disable + "disableOverride" directive takes precedence over the "disable" directive. As a result of this change the disable family of - methods has moved from the BasicConfigurator class to the Hierarchy - class. [**] - - The following perl command can help: - - perl -p -i.bak -e "s/configuration/log4j:configuration/;" file1.xml .. fileN.xml + methods in BasicConfigurator has been deprecated and replaced by the same + family of methods in the Hierarchy class. [*] - The FileAppender has been split into three parts: WriterAppender, ConsoleAppender and FileAppender. ConsoleAppender takes over the 1.1 jakarta-log4j/docs/.cvsignore Index: .cvsignore =================================================================== api 1.1 jakarta-log4j/src/java/Makefile Index: Makefile =================================================================== PKG_DIR :=. DEPTH :=../.. JSOURCES:= SUBDIRS := org # include master-rule file include $(DEPTH)/make/make.inc 1.12 +64 -61 jakarta-log4j/src/java/org/apache/log4j/BasicConfigurator.java Index: BasicConfigurator.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/BasicConfigurator.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- BasicConfigurator.java 2001/02/21 22:28:13 1.11 +++ BasicConfigurator.java 2001/04/14 06:57:21 1.12 @@ -117,8 +117,63 @@ } } + /** + See {@link Hierarchy#disable(String)}. + + @deprecated Use <code>Category.getDefaultHierarchy().disable()</code> instead. */ + public + void disable(String priorityStr) { + Category.getDefaultHierarchy().disable(priorityStr); + } + + /** + See {@link Hierarchy#disable(Priority)}. + + @deprecated Use <code>Category.getDefaultHierarchy().disable(p)</code> instead. */ + public + void disable(Priority p) { + + } + /** + See {@link Hierarchy#disableAll()}. + + @deprecated Use <code>Category.getDefaultHierarchy().disableAll()</code> instead. */ + public + void disableAll() { + Category.getDefaultHierarchy().disable(Priority.FATAL); + } + + /** + See {@link Hierarchy#disableDebug()}. + + @deprecated Use <code>Category.getDefaultHierarchy().disableDebug()</code> instead. */ + public + void disableDebug() { + Category.getDefaultHierarchy().disable(Priority.DEBUG); + } + + /** + See {@link Hierarchy#disableInfo()}. + + @deprecated Use <code>Category.getDefaultHierarchy().disableInfo()</code> instead. */ + public + void disableInfo() { + Category.getDefaultHierarchy().disable(Priority.INFO); + } + + + /** + See {@link Hierarchy#enableAll()}. + + @deprecated Use <code>Category.getDefaultHierarchy().enableAll()</code> instead. */ + public + void enableAll() { + Category.getDefaultHierarchy().disable(Priority.INFO); + } + + /** Add a {@link FileAppender} that uses {@link PatternLayout} using the {@link PatternLayout#TTCC_CONVERSION_PATTERN} and prints to <code>System.out</code> to the root category. */ @@ -142,75 +197,23 @@ } /** - Reset the configuration to its default. This removes all - appenders from all categories, sets the priority of all non-root - categories to <code>null</code>, their additivity flag to - <code>true</code> and sets the priority of the root category to - {@link Priority#DEBUG DEBUG}. Moreover, message disabling is set - its default "off" value. - - <p>This method should be used sparingly and with care as it will - block all logging until it is completed.</p> - - @since version 0.8.5 */ + Reset the default hierarchy to its defaut. It is equivalent to + calling + <code>Category.getDefaultHierarchy().resetConfiguration()</code>. + + See {@link Hierarchy#resetConfiguration()} for more details. */ public static void resetConfiguration() { - - Category.defaultHierarchy.getRoot().setPriority(Priority.DEBUG); - Category.defaultHierarchy.root.setResourceBundle(null); - Category.defaultHierarchy.disable = Hierarchy.DISABLE_OFF; - - // the synchronization is needed to prevent JDK 1.2.x hashtable - // surprises - synchronized(Category.defaultHierarchy.ht) { - Category.defaultHierarchy.shutdown(); // nested locks are OK - - Enumeration cats = Category.getCurrentCategories(); - while(cats.hasMoreElements()) { - Category c = (Category) cats.nextElement(); - c.setPriority(null); - c.setAdditivity(true); - c.setResourceBundle(null); - } - } - Category.defaultHierarchy.rendererMap.clear(); + Category.defaultHierarchy.resetConfiguration(); } /** - Reset the configuration to its default. This removes all - appenders from all categories, sets the priority of all non-root - categories to <code>null</code>, their additivity flad to - <code>true</code> and sets the priority of the root category to - {@link Priority#DEBUG DEBUG}. Moreover, message disabling is set - its default "off" value. - - <p>This method should be used sparingly and with care as it will - block all logging until it is completed.</p> - - @since version 0.8.5 */ + @deprecated Use <code>hierarchy.resetConfiguration()</code> instead. + */ public static void resetConfiguration(Hierarchy hierarchy) { - - hierarchy.getRoot().setPriority(Priority.DEBUG); - hierarchy.root.setResourceBundle(null); - hierarchy.disable = Hierarchy.DISABLE_OFF; - - // the synchronization is needed to prevent JDK 1.2.x hashtable - // surprises - synchronized(hierarchy.ht) { - hierarchy.shutdown(); // nested locks are OK - - Enumeration cats = hierarchy.getCurrentCategories(); - while(cats.hasMoreElements()) { - Category c = (Category) cats.nextElement(); - c.setPriority(null); - c.setAdditivity(true); - c.setResourceBundle(null); - } - } - hierarchy.rendererMap.clear(); + hierarchy.resetConfiguration(); } - } 1.7 +2 -2 jakarta-log4j/src/java/org/apache/log4j/ConsoleAppender.java Index: ConsoleAppender.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/ConsoleAppender.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- ConsoleAppender.java 2001/04/03 16:37:07 1.6 +++ ConsoleAppender.java 2001/04/14 06:57:22 1.7 @@ -12,8 +12,8 @@ import org.apache.log4j.helpers.OptionConverter; /** - ConsoleAppender appends log events to <code>System.err</code> or - <code>System.out</code> using a layout specified by the + ConsoleAppender appends log events to <code>System.out</code> or + <code>System.err</code> using a layout specified by the user. The default target is <code>System.out</code>. @author Ceki Gülcü 1.14 +109 -64 jakarta-log4j/src/java/org/apache/log4j/Hierarchy.java Index: Hierarchy.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/Hierarchy.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- Hierarchy.java 2001/02/21 22:28:14 1.13 +++ Hierarchy.java 2001/04/14 06:57:22 1.14 @@ -5,15 +5,16 @@ * License version 1.1, a copy of which has been included with this * distribution in the LICENSE.APL file. */ -// WARNING This class MUST not have a static initiliazer that -// WARNING references the Category or RootCategory classes neither +// WARNING This class MUST not have references to the Category or +// WARNING RootCategory classes in its static initiliazation neither // WARNING directly nor indirectly. // Contributors: // Luke Blanshard <[EMAIL PROTECTED]> // Mario Schomburg - IBM Global Services/Germany // Anders Kristensen - +// Igor Poteryaev + package org.apache.log4j; @@ -131,14 +132,18 @@ } } + + /** + Similar to {@link #disable(Priority)} except that the priority + argument is given as a String. */ public - void disable(String disableStr) { + void disable(String priorityStr) { if(disable != DISABLE_OVERRIDE) { - Priority p = Priority.toPriority(disableStr, null); + Priority p = Priority.toPriority(priorityStr, null); if(p != null) { disable = p.level; } else { - LogLog.warn("Could not convert ["+disableStr+"] to Priority."); + LogLog.warn("Could not convert ["+priorityStr+"] to Priority."); } } } @@ -146,15 +151,15 @@ /** Disable all logging requests of priority <em>equal to or - below</em> the priority parameter <code>p</code>, regardless of - the request category. Logging requests of higher priority then - the priority of <code>p</code> remain unaffected. + below</em> the priority parameter <code>p</code>, for + <em>all</em> categories in this hierarchy. Logging requests of + higher priority then <code>p</code> remain unaffected. <p>Nevertheless, if the {@link BasicConfigurator#DISABLE_OVERRIDE_KEY} system property is set to "true" or any value other than "false", then logging requests are evaluated as usual, i.e. according to the <a - href="../../manual.html#selectionRule">Basic Selection Rule</a>. + href="../../../../manual.html#selectionRule">Basic Selection Rule</a>. <p>The "disable" family of methods are there for speed. They allow printing methods such as debug, info, etc. to return @@ -363,7 +368,101 @@ return root; } + /** + Reset all values contained in this hierarchy instance to their + default. This removes all appenders from all categories, sets + the priority of all non-root categories to <code>null</code>, + sets their additivity flag to <code>true</code> and sets the priority + of the root category to {@link Priority#DEBUG DEBUG}. Moreover, + message disabling is set its default "off" value. + + <p>Existing categories are not removed. They are just reset. + + <p>This method should be used sparingly and with care as it will + block all logging until it is completed.</p> + + @since version 0.8.5 */ + public + void resetConfiguration() { + + getRoot().setPriority(Priority.DEBUG); + root.setResourceBundle(null); + disable = Hierarchy.DISABLE_OFF; + + // the synchronization is needed to prevent JDK 1.2.x hashtable + // surprises + synchronized(ht) { + shutdown(); // nested locks are OK + + Enumeration cats = getCurrentCategories(); + while(cats.hasMoreElements()) { + Category c = (Category) cats.nextElement(); + c.setPriority(null); + c.setAdditivity(true); + c.setResourceBundle(null); + } + } + rendererMap.clear(); + } + + /** + Set the disable override value given a string. + + @since 1.1 + */ + public + void setDisableOverride(String override) { + if(OptionConverter.toBoolean(override, true)) { + LogLog.debug("Overriding disable."); + disable = DISABLE_OVERRIDE; + } + } + + + + /** + Shutting down a hierarchy will <em>safely</em> close and remove + all appenders in all categories including the root category. + + <p>Some appenders such as {@link org.apache.log4j.net.SocketAppender} + and {@link AsyncAppender} need to be closed before the + application exists. Otherwise, pending logging events might be + lost. + + <p>The <code>shutdown</code> method is careful to close nested + appenders before closing regular appenders. This is allows + configurations where a regular appender is attached to a category + and again to a nested appender. + + + @since 1.0 */ + public + void shutdown() { + Category root = getRoot(); + + // begin by closing nested appenders + root.closeNestedAppenders(); + + synchronized(ht) { + Enumeration cats = this.getCurrentCategories(); + while(cats.hasMoreElements()) { + Category c = (Category) cats.nextElement(); + c.closeNestedAppenders(); + } + + // then, remove all appenders + root.removeAllAppenders(); + cats = this.getCurrentCategories(); + while(cats.hasMoreElements()) { + Category c = (Category) cats.nextElement(); + c.removeAllAppenders(); + } + } + } + + + /** This method loops through all the *potential* parents of 'cat'. There 3 possible cases: @@ -457,60 +556,6 @@ } } - /** - Set the disable override value given a string. - - @since 1.1 - */ - public - void setDisableOverride(String override) { - if(OptionConverter.toBoolean(override, true)) { - LogLog.debug("Overriding disable."); - disable = DISABLE_OVERRIDE; - } - } - - - - /** - Shutting down a hierarchy will <em>safely</em> close and remove - all appenders in all categories including the root category. - - <p>Some appenders such as {@link org.apache.log4j.net.SocketAppender} - and {@link AsyncAppender} need to be closed before the - application exists. Otherwise, pending logging events might be - lost. - - <p>The <code>shutdown</code> method is careful to close nested - appenders before closing regular appenders. This is allows - configurations where a regular appender is attached to a category - and again to a nested appender. - - - @since 1.0 */ - public - void shutdown() { - Category root = getRoot(); - - // begin by closing nested appenders - root.closeNestedAppenders(); - - synchronized(ht) { - Enumeration cats = this.getCurrentCategories(); - while(cats.hasMoreElements()) { - Category c = (Category) cats.nextElement(); - c.closeNestedAppenders(); - } - - // then, remove all appenders - root.removeAllAppenders(); - cats = this.getCurrentCategories(); - while(cats.hasMoreElements()) { - Category c = (Category) cats.nextElement(); - c.removeAllAppenders(); - } - } - } } 1.1 jakarta-log4j/src/java/org/apache/log4j/examples/.cvsignore Index: .cvsignore =================================================================== doc-files 1.7 +2 -2 jakarta-log4j/src/java/org/apache/log4j/spi/OptionHandler.java Index: OptionHandler.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/spi/OptionHandler.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- OptionHandler.java 2001/04/03 16:37:33 1.6 +++ OptionHandler.java 2001/04/14 06:57:22 1.7 @@ -36,7 +36,7 @@ /** Return list of strings that the OptionHandler instance recognizes. - @deprecated use JavaBeans style getters/setters + @deprecated We now use JavaBeans style getters/setters. */ String[] getOptionStrings(); @@ -48,7 +48,7 @@ other may be activated only when {@link #activateOptions} is called. - @deprecated use JavaBeans style getters/setters + @deprecated We now use JavaBeans style getters/setters. */ void setOption(String option, String value); } 1.5 +1 -2 jakarta-log4j/src/java/org/apache/log4j/xml/test/do1.xml Index: do1.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/test/do1.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- do1.xml 2001/01/17 14:26:58 1.4 +++ do1.xml 2001/04/14 06:57:22 1.5 @@ -9,8 +9,7 @@ with a specifed DTD --> <log4j:configuration> - <appender name="A1" class="org.apache.log4j.FileAppender"> - <param name="File" value="System.out" /> + <appender name="A1" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="TEST1: %-5p %c{2} - %m%n"/> 1.5 +1 -3 jakarta-log4j/src/java/org/apache/log4j/xml/test/do2.xml Index: do2.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/test/do2.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- do2.xml 2001/01/17 14:26:58 1.4 +++ do2.xml 2001/04/14 06:57:22 1.5 @@ -9,9 +9,7 @@ with a specifed DTD --> <log4j:configuration disableOverride="true"> - <appender name="A1" class="org.apache.log4j.FileAppender"> - - <param name="File" value="System.out" /> + <appender name="A1" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="TEST2: %5p %c{2} - %m%n"/> 1.5 +1 -3 jakarta-log4j/src/java/org/apache/log4j/xml/test/do3.xml Index: do3.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/test/do3.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- do3.xml 2001/01/17 14:26:58 1.4 +++ do3.xml 2001/04/14 06:57:22 1.5 @@ -9,9 +9,7 @@ with a specifed DTD --> <log4j:configuration disableOverride="false"> - <appender name="A1" class="org.apache.log4j.FileAppender"> - <param name="File" value="System.out" /> - + <appender name="A1" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="TEST 3: %-5p %c - %m%n"/> 1.5 +1 -3 jakarta-log4j/src/java/org/apache/log4j/xml/test/do4.xml Index: do4.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/test/do4.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- do4.xml 2001/01/17 14:26:58 1.4 +++ do4.xml 2001/04/14 06:57:22 1.5 @@ -9,9 +9,7 @@ with a specifed DTD --> <log4j:configuration> - <appender name="A1" class="org.apache.log4j.FileAppender"> - - <param name="File" value="System.out" /> + <appender name="A1" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="TEST4: %-5p %c{2} - %m%n"/> 1.5 +1 -3 jakarta-log4j/src/java/org/apache/log4j/xml/test/do5.xml Index: do5.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/test/do5.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- do5.xml 2001/01/17 14:26:58 1.4 +++ do5.xml 2001/04/14 06:57:22 1.5 @@ -9,9 +9,7 @@ with a specifed DTD --> <log4j:configuration disableOverride="true"> - <appender name="A1" class="org.apache.log4j.FileAppender"> - - <param name="File" value="System.out" /> + <appender name="A1" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="TEST5: %5p %c{2} - %m%n"/> 1.5 +1 -3 jakarta-log4j/src/java/org/apache/log4j/xml/test/do6.xml Index: do6.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/test/do6.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- do6.xml 2001/01/17 14:26:58 1.4 +++ do6.xml 2001/04/14 06:57:22 1.5 @@ -9,9 +9,7 @@ with a specifed DTD --> <log4j:configuration disableOverride="false"> - <appender name="A1" class="org.apache.log4j.FileAppender"> - <param name="File" value="System.out" /> - + <appender name="A1" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="TEST 6: %-5p %c - %m%n"/> 1.5 +1 -3 jakarta-log4j/src/java/org/apache/log4j/xml/test/do7.xml Index: do7.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/test/do7.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- do7.xml 2001/01/17 14:26:58 1.4 +++ do7.xml 2001/04/14 06:57:22 1.5 @@ -9,9 +9,7 @@ without a DTD --> <log4j:configuration> - <appender name="A1" class="org.apache.log4j.FileAppender"> - - <param name="File" value="System.out" /> + <appender name="A1" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="(TEST 7) %t %c - %m%n"/> 1.5 +1 -3 jakarta-log4j/src/java/org/apache/log4j/xml/test/do8.xml Index: do8.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/test/do8.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- do8.xml 2001/01/17 14:26:58 1.4 +++ do8.xml 2001/04/14 06:57:22 1.5 @@ -9,9 +9,7 @@ without DTD --> <log4j:configuration disableOverride="true"> - <appender name="A1" class="org.apache.log4j.FileAppender"> - - <param name="File" value="System.out" /> + <appender name="A1" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="TEST8: %5p %c{2} - %m%n"/> 1.5 +1 -3 jakarta-log4j/src/java/org/apache/log4j/xml/test/do9.xml Index: do9.xml =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/test/do9.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- do9.xml 2001/01/17 14:26:58 1.4 +++ do9.xml 2001/04/14 06:57:22 1.5 @@ -10,9 +10,7 @@ --> <log4j:configuration disableOverride="false"> - <appender name="A1" class="org.apache.log4j.FileAppender"> - <param name="File" value="System.out" /> - + <appender name="A1" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="TEST 9: %-5p %c - %m%n"/> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]