You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by ce...@apache.org on 2001/05/20 16:03:32 UTC
cvs commit: jakarta-log4j/src/java/org/apache/log4j/test customCategory runAll
ceki 01/05/20 07:03:32
Modified: src/java/org/apache/log4j PropertyConfigurator.java
src/java/org/apache/log4j/config PropertySetter.java
src/java/org/apache/log4j/examples MyCategory.java mycat.bad
mycat.good
src/java/org/apache/log4j/test customCategory runAll
Log:
Added missing custom priority support in PropertyConfigurator.java. Added a related test case.
Revision Changes Path
1.22 +9 -19 jakarta-log4j/src/java/org/apache/log4j/PropertyConfigurator.java
Index: PropertyConfigurator.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/PropertyConfigurator.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- PropertyConfigurator.java 2001/05/20 13:21:57 1.21
+++ PropertyConfigurator.java 2001/05/20 14:03:31 1.22
@@ -140,16 +140,10 @@
<p>This syntax means that an optional <em>priority value</em> can
be supplied followed by appender names separated by commas.
-
-
-
<p>The priority value can consist of the string values FATAL,
- ERROR, WARN, INFO or DEBUG. However, you can specify a custom
- priority value in the form <code>priority#classname</code>. In
- that case, the specified class' toPriority method is called to
- process the specified priority string; if no '#' character is
- present, then the default {@link Priority} class is used to
- process the priority value.
+ ERROR, WARN, INFO, DEBUG or a <em>custom priority</em> value. A
+ custom priority value can be specified in the form
+ <code>priority#classname</code>.
<p>If one of the optional priority value is specified, then the
root priority is set to the corresponding priority. If no
@@ -164,15 +158,13 @@
<p>For non-root categories the syntax is almost the same:
<pre>
- log4j.category.category_name=[INHERITED|FATAL|ERROR|WARN|INFO|DEBUG], appenderName, appenderName, ...
+ log4j.category.category_name=[priority|INHERITED], appenderName, appenderName, ...
</pre>
- <p>Thus, one of the usual priority values FATAL, ERROR, WARN,
- INFO, or DEBUG can be optionally specified. For any any of these
- values the named category is assigned the corresponding
- priority. In addition however, the value INHERITED can be
- optionally specified which means that named category should
- inherit its priority from the category hierarchy.
+ <p>The meaning of the priority value is discussed above in
+ relation to the root category. In addition however, the value
+ INHERITED can be optionally specified meaning that the named
+ category should inherit its priority from the category hierarchy.
<p>If no priority value is supplied, then the priority of the
named category remains untouched.
@@ -192,7 +184,7 @@
<p>The user can override any of the {@link
Hierarchy#disable} family of methods by setting the a key
"log4j.disableOverride" to <code>true</code> or any value other
- than false. As in <pre> log4j.disableOverride=true </pre>
+ than false. As in <pre>log4j.disableOverride=true </pre>
<h3>ObjectRenderers</h3>
@@ -586,8 +578,6 @@
}
}
}
-
-
Appender parseAppender(Properties props, String appenderName) {
Appender appender = registryGet(appenderName);
1.6 +1 -1 jakarta-log4j/src/java/org/apache/log4j/config/PropertySetter.java
Index: PropertySetter.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/config/PropertySetter.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- PropertySetter.java 2001/04/17 22:32:29 1.5
+++ PropertySetter.java 2001/05/20 14:03:31 1.6
@@ -223,7 +223,7 @@
return Boolean.FALSE;
}
} else if (Priority.class.isAssignableFrom(type)) {
- return OptionConverter.toPriority(v, null);
+ return OptionConverter.toPriority(v, Priority.DEBUG);
}
return null;
}
1.6 +2 -1 jakarta-log4j/src/java/org/apache/log4j/examples/MyCategory.java
Index: MyCategory.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/examples/MyCategory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MyCategory.java 2001/02/13 17:37:15 1.5
+++ MyCategory.java 2001/05/20 14:03:32 1.6
@@ -64,7 +64,8 @@
}
try {
MyCategory c = (MyCategory) MyCategory.getInstance("some.cat");
- c.debug("Hello");
+ c.trace("Hello");
+ c.debug("World.");
} catch(ClassCastException e) {
LogLog.error("Did you forget to set the factory in the config file?", e);
}
1.4 +6 -5 jakarta-log4j/src/java/org/apache/log4j/examples/mycat.bad
Index: mycat.bad
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/examples/mycat.bad,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- mycat.bad 2001/04/22 15:30:31 1.3
+++ mycat.bad 2001/05/20 14:03:32 1.4
@@ -6,10 +6,11 @@
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%c - %m%n
+# Set the priority of "some.cat" to TRACE (defined in
+# org.apache.log4j.xml.examples.XPriority). This will actually have
+# the side effect of instanciating a category object having the name
+# "some.cat" this will cause a ClassCastException if the category
+# object is cast as a MyCategory object.
-# Set the priority of "some.cat". This will have the side effect of
-# instantiating the category "some.cat" which will later cause a
-# ClassCastException.
-
-log4j.category.some.cat=DEBUG
+log4j.category.some.cat=TRACE#org.apache.log4j.xml.examples.XPriority
1.5 +6 -4 jakarta-log4j/src/java/org/apache/log4j/examples/mycat.good
Index: mycat.good
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/examples/mycat.good,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- mycat.good 2001/04/22 15:30:31 1.4
+++ mycat.good 2001/05/20 14:03:32 1.5
@@ -14,9 +14,11 @@
log4j.appender.A1.layout.ConversionPattern=[%t] %c - %m%n
-# Set the priority of "some.cat". This will actually have the side
-# effect of instanciating a MyCategory object having the name
-# "some.cat".
+# Set the priority of "some.cat" to TRACE (defined in
+# org.apache.log4j.xml.examples.XPriority). Since we specified
+# MyCategoryFactory as the category factory, the following line willl
+# also have the side effect of instanciating a MyCategory object
+# having the name "some.cat".
-log4j.category.some.cat=DEBUG
+log4j.category.some.cat=TRACE#org.apache.log4j.xml.examples.XPriority
1.2 +2 -2 jakarta-log4j/src/java/org/apache/log4j/test/customCategory
Index: customCategory
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/customCategory,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- customCategory 2001/05/20 13:21:57 1.1
+++ customCategory 2001/05/20 14:03:32 1.2
@@ -13,9 +13,9 @@
layout=$1
echo -n "Custom Priority test $TEST - "
- java org.apache.log4j.test.CustomCategoryTest $LCF
+ java -Dlog4j.debug org.apache.log4j.test.CustomCategoryTest $LCF
- check witness/customCat.$TEST $OUTPUT; echo "OK."
+ check witness/customCat.$TEST $TEMP; echo "OK."
}
1.4 +1 -0 jakarta-log4j/src/java/org/apache/log4j/test/runAll
Index: runAll
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/runAll,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- runAll 2001/01/26 13:27:47 1.3
+++ runAll 2001/05/20 14:03:32 1.4
@@ -9,6 +9,7 @@
./shippedCodeFlag || die "shippedCodeFlag test FAILED."
./defaultInit || die "defaultInit test FAILED."
./propConfig || die "propConfig test FAILED."
+./propConfig || die "propConfig test FAILED."
./getOptions || die "getOptions test FAILED."
./multipleAppenders || die "multipleAppenders test FAILED."
./confParsing || die "confParsing test FAILED."
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-cvs-help@jakarta.apache.org