ceki 2003/09/11 10:00:42
Modified: docs .cvsignore TODO
src/java/org/apache/joran/action ParamAction.java
AppenderAction.java AppenderRefAction.java
Action.java
src/java/org/apache/log4j/config PropertySetter.java
src/java/org/apache/log4j/xml DOMConfigurator.java
tests/src/java/org/apache/joran JoranParserTest.java
Added: src/java/org/apache/joran/action LayoutAction.java
Log:
Joran can now configure appenders and layouts and attach them to loggers.
Revision Changes Path
1.3 +2 -0 jakarta-log4j/docs/.cvsignore
Index: .cvsignore
===================================================================
RCS file: /home/cvs/jakarta-log4j/docs/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- .cvsignore 2 Sep 2003 18:54:35 -0000 1.2
+++ .cvsignore 11 Sep 2003 17:00:41 -0000 1.3
@@ -3,3 +3,5 @@
index-files
org
contributors.html
+plan.html
+download.html
1.5 +1 -5 jakarta-log4j/docs/TODO
Index: TODO
===================================================================
RCS file: /home/cvs/jakarta-log4j/docs/TODO,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TODO 21 May 2003 18:59:59 -0000 1.4
+++ TODO 11 Sep 2003 17:00:41 -0000 1.5
@@ -3,18 +3,14 @@
TODO
-- Improve the concurrency model of the Logger class
+- Improve the concurrency model of the Logger class (partially done)
- Log4j self configuration
-
- Add support for string options in SocketAppender
- Add a properties file option to log4j:configure in XML.
-
- Graceful congiguration merging
-- Integrate tons of GUI code.
- JDBCAppender.
-- Time based rolling.
- SSL logging.
- Authenticated logging.
1.2 +21 -5 jakarta-log4j/src/java/org/apache/joran/action/ParamAction.java
Index: ParamAction.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/joran/action/ParamAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ParamAction.java 10 Sep 2003 16:28:19 -0000 1.1
+++ ParamAction.java 11 Sep 2003 17:00:42 -0000 1.2
@@ -12,14 +12,30 @@
final static Logger logger = Logger.getLogger(ParamAction.class);
- static final Class[] ONE_STRING_PARAM = new Class[] { String.class };
-
+ static String NO_NAME = "No name attribute in <param> element";
+ static String NO_VALUE = "No name attribute in <param> element";
+
public void begin(ExecutionContext ec, Element element) {
- logger.info("begin called");
- Object o = ec.peekObject();
- PropertySetter propSetter = new PropertySetter(o);
String name = element.getAttribute(ActionConst.NAME_ATTRIBUTE);
String value = (element.getAttribute(ActionConst.VALUE_ATTRIBUTE));
+
+ if(name==null) {
+ inError = true;
+ logger.error(NO_NAME);
+ ec.addError(NO_NAME);
+ return;
+ }
+
+ if(value==null) {
+ inError = true;
+ logger.error(NO_VALUE);
+ ec.addError(NO_VALUE);
+ return;
+ }
+
+ logger.debug("Setting parameter ["+name+"] to value ["+value+"].");
+ Object o = ec.peekObject();
+ PropertySetter propSetter = new PropertySetter(o);
value = ec.subst(OptionConverter.convertSpecialChars(value));
propSetter.setProperty(name, value);
}
1.2 +108 -37
jakarta-log4j/src/java/org/apache/joran/action/AppenderAction.java
Index: AppenderAction.java
===================================================================
RCS file:
/home/cvs/jakarta-log4j/src/java/org/apache/joran/action/AppenderAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AppenderAction.java 10 Sep 2003 16:28:19 -0000 1.1
+++ AppenderAction.java 11 Sep 2003 17:00:42 -0000 1.2
@@ -1,67 +1,138 @@
+/*
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "log4j" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/>.
+ *
+ */
+
package org.apache.joran.action;
import org.apache.joran.ExecutionContext;
+
import org.apache.log4j.Appender;
import org.apache.log4j.Logger;
-import org.apache.log4j.helpers.Loader;
+import org.apache.log4j.helpers.OptionConverter;
import org.apache.log4j.spi.OptionHandler;
-import org.w3c.dom.Element;
-
-public class AppenderAction extends Action {
-
- final static Logger logger = Logger.getLogger(AppenderAction.class);
+import org.w3c.dom.Element;
- static final Class[] ONE_STRING_PARAM = new Class[] { String.class };
+import java.util.HashMap;
- Logger logger2Attach = null;
+public class AppenderAction extends Action {
+ static final Logger logger = Logger.getLogger(AppenderAction.class);
Appender appender;
-
- public void begin(ExecutionContext ec, Element appenderElement) {
-
- Object o = ec.peekObject();
-
- if (!(o instanceof Logger)) {
- logger.warn("Could not find a logger at the top of execution stack.");
- inError = true;
- ec.addError(
- "For element <level>, could not find a logger at the top of execution
stack.");
- return;
- }
-
- logger2Attach = (Logger) o;
+ /**
+ * Instantiates an appender of the given class and sets its name.
+ *
+ * The appender thus generated is placed in the ExecutionContext appender bag.
+ */
+ public void begin(ExecutionContext ec, Element appenderElement) {
String className =
appenderElement.getAttribute(ActionConst.CLASS_ATTRIBUTE);
- logger.debug("Class name: [" + className + ']');
try {
- Object instance = Loader.loadClass(className).newInstance();
+ logger.debug(
+ "About to instantiate appender of type [" + className + "]");
+
+ Object instance =
+ OptionConverter.instantiateByClassName(
+ className, org.apache.log4j.Appender.class, null);
appender = (Appender) instance;
- String appenderName =
appenderElement.getAttribute(ActionConst.NAME_ATTRIBUTE);
- if(appenderName == null) {
- logger.warn("No appender name given for appender of
type "+className
- +"].");
- } else {
+
+ String appenderName =
+ appenderElement.getAttribute(ActionConst.NAME_ATTRIBUTE);
+
+ if (appenderName == null) {
+ logger.warn(
+ "No appender name given for appender of type " + className + "].");
+ } else {
appender.setName(appenderName);
- }
+ logger.debug("Appender named as [" + appenderName + "]");
+ }
+
+ HashMap appenderBag =
+ (HashMap) ec.getObjectMap().get(ActionConst.APPENDER_BAG);
+ appenderBag.put(appenderName, appender);
+
+ logger.debug("Pushing appender on to the object stack.");
ec.pushObject(appender);
} catch (Exception oops) {
- inError = true;
+ inError = true;
logger.error(
"Could not create an Appender. Reported error follows.", oops);
- ec.addError("Could not create appender of type "+className+"].");
+ ec.addError("Could not create appender of type " + className + "].");
}
-
}
+ /**
+ * Once the children elements are also parsed, now is the time to activate
+ * the appender options.
+ */
public void end(ExecutionContext ec, Element e) {
- if (inError)
+ if (inError) {
return;
- if(appender instanceof OptionHandler) {
- ((OptionHandler)appender).activateOptions();
- }
+ }
+
+ if (appender instanceof OptionHandler) {
+ ((OptionHandler) appender).activateOptions();
+ }
+
+ Object o = ec.peekObject();
+
+ if (o != appender) {
+ logger.warn(
+ "The object at the of the stack is not the appender named ["
+ + appender.getName() + "] pushed earlier.");
+ } else {
+ logger.warn(
+ "Popping appender named [" + appender.getName()
+ + "] from the object stack");
+ ec.popObject();
+ }
}
public void finish(ExecutionContext ec) {
1.2 +112 -93
jakarta-log4j/src/java/org/apache/joran/action/AppenderRefAction.java
Index: AppenderRefAction.java
===================================================================
RCS file:
/home/cvs/jakarta-log4j/src/java/org/apache/joran/action/AppenderRefAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AppenderRefAction.java 10 Sep 2003 16:28:19 -0000 1.1
+++ AppenderRefAction.java 11 Sep 2003 17:00:42 -0000 1.2
@@ -1,110 +1,129 @@
-package org.apache.joran.action;
+/*
+ * ============================================================================
+ * The Apache Software License, Version 1.1
+ * ============================================================================
+ *
+ * Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modifica-
+ * tion, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if any, must
+ * include the following acknowledgment: "This product includes software
+ * developed by the Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself, if
+ * and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "log4j" and "Apache Software Foundation" must not be used to
+ * endorse or promote products derived from this software without prior
+ * written permission. For written permission, please contact
+ * [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache", nor may
+ * "Apache" appear in their name, without prior written permission of the
+ * Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
+ * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * on behalf of the Apache Software Foundation. For more information on the
+ * Apache Software Foundation, please see <http://www.apache.org/>.
+ *
+ */
-import java.util.HashMap;
+package org.apache.joran.action;
import org.apache.joran.ExecutionContext;
-import org.apache.joran.JoranParser;
-import org.apache.joran.Pattern;
-
import org.apache.log4j.Appender;
import org.apache.log4j.Logger;
-import org.w3c.dom.Document;
+import org.apache.log4j.spi.AppenderAttachable;
+
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
+import java.util.HashMap;
public class AppenderRefAction extends Action {
+ static final Logger logger = Logger.getLogger(AppenderRefAction.class);
+
+ public void begin(ExecutionContext ec, Element appenderRef) {
+ logger.debug("begin called");
+
+ Object o = ec.peekObject();
+
+ if (!(o instanceof AppenderAttachable)) {
+ logger.warn(
+ "Could not find an AppenderAttachable object at the top of execution
stack.");
+ inError = true;
+ ec.addError(
+ "For element <appender-ref>, could not find a AppenderAttachable object at
the top of execution stack.");
- final static Logger logger = Logger.getLogger(AppenderRefAction.class);
-
- public void begin(ExecutionContext ec, Element appenderRef) {
- logger.debug("begin called");
-
- Object o = ec.peekObject();
-
- if(!(o instanceof Logger)) {
- logger.warn("Could not find a logger at the top of execution
stack.");
- inError = true;
- ec.addError("For element <appender-ref>, could not find a
logger at the top of execution stack.");
- return;
- }
- Logger l = (Logger) o;
-
- String appenderName =
appenderRef.getAttribute(ActionConst.REF_ATTRIBUTE);
- if(appenderName == null) {
- // print a meaningful error message and return
- Node parentNode = appenderRef.getParentNode();
- String errMsg = "Missing appender ref attribute in
<appender-ref> tag.";
- if(parentNode instanceof Element){
- Element parentElement = (Element) parentNode;
- String parentTag = parentElement.getTagName();
-
- if("logger".equals(parentTag)) {
- String loggerName =
parentElement.getAttribute("name");
- errMsg = errMsg + " Within <"+parentTag+">"
- + " named ["+loggerName+"].";
- } {
- errMsg = errMsg + " Within <"+parentTag+">";
- }
}
- parentNode.getAttributes();
- logger.warn(errMsg);
- inError = true;
- ec.addError(errMsg);
return;
- }
-
- // let's get the appender
- getAppenderByRef(ec, appenderRef, appenderName);
- Appender appender = (Appender) ec.peekObject();
-
- if(appender == null) {
- logger.warn("Could not find an appender named
["+appenderName+"]");
- inError = true;
- ec.addError("Could not find an appender named
["+appenderName+"]");
+ }
+
+ AppenderAttachable appenderAttachable = (AppenderAttachable) o;
+
+ String appenderName = appenderRef.getAttribute(ActionConst.REF_ATTRIBUTE);
+
+ if (appenderName == null) {
+ // print a meaningful error message and return
+ Node parentNode = appenderRef.getParentNode();
+ String errMsg = "Missing appender ref attribute in <appender-ref> tag.";
+
+ if (parentNode instanceof Element) {
+ Element parentElement = (Element) parentNode;
+ String parentTag = parentElement.getTagName();
+
+ if ("logger".equals(parentTag)) {
+ String loggerName = parentElement.getAttribute("name");
+ errMsg =
+ errMsg + " Within <" + parentTag + ">" + " named [" + loggerName
+ + "].";
+ }
+
+ errMsg = errMsg + " Within <" + parentTag + ">";
+ }
+
+ parentNode.getAttributes();
+ logger.warn(errMsg);
+ inError = true;
+ ec.addError(errMsg);
+
+ return;
+ }
+
+ HashMap appenderBag =
+ (HashMap) ec.getObjectMap().get(ActionConst.APPENDER_BAG);
+ Appender appender = (Appender) appenderBag.get(appenderName);
+
+ if (appender == null) {
+ logger.warn("Could not find an appender named [" + appenderName + "]");
+ inError = true;
+ ec.addError("Could not find an appender named [" + appenderName + "]");
+ return;
}
-
- // cat.addAppender(appender);
- }
-
-
- void getAppenderByRef(ExecutionContext ec, Element appenderRef,
- String appenderName) {
-
- HashMap appenderBag = (HashMap)
ec.getObjectMap().get(ActionConst.APPENDER_BAG);
- Appender appender = (Appender) appenderBag.get(appenderName);
- if (appender != null) {
- ec.pushObject(appender);
- } else {
- // find the right elenet with appender tag and name
'appenderName'
- Element root = appenderRef.getOwnerDocument().getDocumentElement();
- Element targetElement = null;
- NodeList nodeList =
root.getElementsByTagName(ActionConst.APPENDER_TAG);
- for(int i = 0; i < nodeList.getLength(); i++) {
- Node n = nodeList.item(i);
- if(n instanceof Element) {
- Element e = (Element) n;
-
if(appenderName.equals(e.getAttribute(ActionConst.NAME_ATTRIBUTE))) {
- targetElement = e; // we found the
appender element we were looking for
- break;
- }
- }
- }
-
- if(targetElement == null) {
- logger.warn("Could not find <appender> elemt named
["+appenderName+"]");
- inError = true;
- ec.addError("Could not find an <appender> element
named ["
- +appenderName+"]");
- return;
- }
-
- JoranParser jp = ec.getJoranParser();
- jp.loop(targetElement, new Pattern("-"));
-
- }
+
+ logger.debug(
+ "Attaching appender named [" + appenderName + "] to "
+ + appenderAttachable);
+ appenderAttachable.addAppender(appender);
}
public void end(ExecutionContext ec, Element e) {
1.3 +0 -1 jakarta-log4j/src/java/org/apache/joran/action/Action.java
Index: Action.java
===================================================================
RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/joran/action/Action.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Action.java 10 Sep 2003 16:28:19 -0000 1.2
+++ Action.java 11 Sep 2003 17:00:42 -0000 1.3
@@ -50,7 +50,6 @@
package org.apache.joran.action;
import org.apache.joran.ExecutionContext;
-import org.apache.log4j.helpers.OptionConverter;
import org.w3c.dom.Element;
1.1 jakarta-log4j/src/java/org/apache/joran/action/LayoutAction.java
Index: LayoutAction.java
===================================================================
/*
* ============================================================================
* The Apache Software License, Version 1.1
* ============================================================================
*
* Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
* tion, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The end-user documentation included with the redistribution, if any, must
* include the following acknowledgment: "This product includes software
* developed by the Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself, if
* and wherever such third-party acknowledgments normally appear.
*
* 4. The names "log4j" and "Apache Software Foundation" must not be used to
* endorse or promote products derived from this software without prior
* written permission. For written permission, please contact
* [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache", nor may
* "Apache" appear in their name, without prior written permission of the
* Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
* DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* on behalf of the Apache Software Foundation. For more information on the
* Apache Software Foundation, please see <http://www.apache.org/>.
*
*/
package org.apache.joran.action;
import org.apache.joran.ExecutionContext;
import org.apache.log4j.Appender;
import org.apache.log4j.Layout;
import org.apache.log4j.Logger;
import org.apache.log4j.helpers.OptionConverter;
import org.apache.log4j.spi.OptionHandler;
import org.w3c.dom.Element;
public class LayoutAction extends Action {
static final Logger logger = Logger.getLogger(LayoutAction.class);
Layout layout;
/**
* Instantiates an layout of the given class and sets its name.
*
*/
public void begin(ExecutionContext ec, Element appenderElement) {
String className =
appenderElement.getAttribute(ActionConst.CLASS_ATTRIBUTE);
try {
logger.debug("About to instantiate layout of type [" + className + "]");
Object instance =
OptionConverter.instantiateByClassName(
className, org.apache.log4j.Layout.class, null);
layout = (Layout) instance;
logger.debug("Pushing layout on top of the object stack.");
ec.pushObject(layout);
} catch (Exception oops) {
inError = true;
logger.error(
"Could not create an Layout. Reported error follows.", oops);
ec.addError("Could not create layout of type " + className + "].");
}
}
/**
* Once the children elements are also parsed, now is the time to activate
* the appender options.
*/
public void end(ExecutionContext ec, Element e) {
if (inError) {
return;
}
if (layout instanceof OptionHandler) {
((OptionHandler) layout).activateOptions();
}
Object o = ec.peekObject();
if (o != layout) {
logger.warn(
"The object on the top the of the stack is not the layout pushed earlier.");
} else {
logger.warn("Popping layout from the object stack");
ec.popObject();
try {
logger.debug("About to set the layout of the containing appender.");
Appender appender = (Appender) ec.peekObject();
appender.setLayout(layout);
} catch(Exception ex) {
logger.error("Could not set the layout for containing appender.", ex);
}
}
}
public void finish(ExecutionContext ec) {
}
}
1.17 +6 -6
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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- PropertySetter.java 16 Oct 2002 13:44:09 -0000 1.16
+++ PropertySetter.java 11 Sep 2003 17:00:42 -0000 1.17
@@ -126,7 +126,7 @@
setProperty(key, value);
}
}
- activate();
+ //activate();
}
/**
@@ -354,9 +354,9 @@
return null;
}
- public void activate() {
- if (obj instanceof OptionHandler) {
- ((OptionHandler) obj).activateOptions();
- }
- }
+ //public void activate() {
+ //if (obj instanceof OptionHandler) {
+ //((OptionHandler) obj).activateOptions();
+ //}
+ //}
}
1.58 +15 -4 jakarta-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java
Index: DOMConfigurator.java
===================================================================
RCS file:
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/xml/DOMConfigurator.java,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- DOMConfigurator.java 2 Sep 2003 18:52:35 -0000 1.57
+++ DOMConfigurator.java 11 Sep 2003 17:00:42 -0000 1.58
@@ -258,7 +258,9 @@
}
}
- propSetter.activate();
+ if(appender instanceof OptionHandler) {
+ ((OptionHandler)appender).activateOptions();
+ }
return appender;
}
@@ -407,7 +409,10 @@
}
}
- propSetter.activate();
+ if(eh instanceof OptionHandler) {
+ ((OptionHandler)eh).activateOptions();
+ }
+
appender.setErrorHandler(eh);
}
}
@@ -439,7 +444,11 @@
}
}
- propSetter.activate();
+ if(filter instanceof OptionHandler) {
+ ((OptionHandler)filter).activateOptions();
+ }
+
+
LogLog.debug(
"Adding filter of type [" + filter.getClass()
+ "] to appender named [" + appender.getName() + "].");
@@ -551,7 +560,9 @@
}
}
- propSetter.activate();
+ if(cat instanceof OptionHandler) {
+ ((OptionHandler)cat).activateOptions();
+ }
}
protected void parseRenderer(Element element) {
1.2 +4 -3
jakarta-log4j/tests/src/java/org/apache/joran/JoranParserTest.java
Index: JoranParserTest.java
===================================================================
RCS file:
/home/cvs/jakarta-log4j/tests/src/java/org/apache/joran/JoranParserTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JoranParserTest.java 11 Sep 2003 16:06:28 -0000 1.1
+++ JoranParserTest.java 11 Sep 2003 17:00:42 -0000 1.2
@@ -14,6 +14,7 @@
import org.apache.joran.action.ActionConst;
import org.apache.joran.action.AppenderAction;
import org.apache.joran.action.AppenderRefAction;
+import org.apache.joran.action.LayoutAction;
import org.apache.joran.action.LevelAction;
import org.apache.joran.action.LoggerAction;
import org.apache.joran.action.ParamAction;
@@ -63,7 +64,7 @@
LogManager.shutdown();
}
- public void testLoop() throws Exception {
+ public void xtestLoop() throws Exception {
logger.debug("Starting testLoop");
DocumentBuilderFactory dbf = null;
@@ -90,7 +91,7 @@
}
public void testLoop2() throws Exception {
- logger.debug("Starting testLoop");
+ logger.debug("Starting testLoop2");
DocumentBuilderFactory dbf = null;
@@ -102,7 +103,6 @@
Document doc =
docBuilder.parse("file:input/joran/parser2.xml");
RuleStore rs = new SimpleRuleStore();
- logger.debug("pattern: "+new
Pattern("log4j:configuration/logger"));
rs.addRule(new Pattern("log4j:configuration/logger"), new
LoggerAction());
rs.addRule(new Pattern("log4j:configuration/logger/level"),
new LevelAction());
rs.addRule(new Pattern("log4j:configuration/root"), new
RootLoggerAction());
@@ -110,6 +110,7 @@
rs.addRule(new Pattern("log4j:configuration/logger/appender-ref"),
new AppenderRefAction());
rs.addRule(new Pattern("log4j:configuration/root/appender-ref"),
new AppenderRefAction());
rs.addRule(new Pattern("log4j:configuration/appender"), new
AppenderAction());
+ rs.addRule(new Pattern("log4j:configuration/appender/layout"), new
LayoutAction());
rs.addRule(new Pattern("*/param"), new ParamAction());
JoranParser jp = new JoranParser(rs);
ExecutionContext ec = jp.getExecutionContext();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]