public void begin(InterpretationContext ec, String localName, Attributes attributes) throws ActionException { // We are just beginning, reset variables appender = null; inError = false;
String className = attributes.getValue(CLASS_ATTRIBUTE); if (OptionHelper.isEmpty(className)) { addError("Missing class name for appender. Near [" + localName + "] line " + getLineNumber(ec)); inError = true; return; }
try { addInfo("About to instantiate appender of type [" + className + "]");
if (OptionHelper.isEmpty(appenderName)) { addWarn("No appender name given for appender of type " + className + "]."); } else { appender.setName(appenderName); addInfo("Naming appender as [" + appenderName + "]"); }
// The execution context contains a bag which contains the appenders // created thus far. HashMap<String, Appender> appenderBag = (HashMap) ec.getObjectMap().get( ActionConst.APPENDER_BAG);
// add the appender just created to the appender bag. appenderBag.put(appenderName, appender);
ec.pushObject(appender); } catch (Exception oops) { inError = true; addError("Could not create an Appender of type [" + className + "].", oops); throw new ActionException(oops); } }
public void begin(InterpretationContext ec, String tagName, Attributes attributes) { // Let us forget about previous errors (in this object) inError = false;
// logger.debug("begin called");
Object o = ec.peekObject();
if (!(o instanceof AppenderAttachable)) { String errMsg = "Could not find an AppenderAttachable at the top of execution stack. Near [" + tagName + "] line " + getLineNumber(ec); inError = true; addError(errMsg); return; }
if (appender == null) { String msg = "Could not find an appender named [" + appenderName + "]. Did you define it below in the config file?"; inError = true; addError(msg); addError("See " + CoreConstants.CODES_URL + "#appender_order for more details."); return; }
addInfo("Attaching appender named [" + appenderName + "] to " + appenderAttachable); appenderAttachable.addAppender(appender); }