@ SuppressWarnings ( "unchecked" ) 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 + "]" ) ; warnDeprecated ( className ) ; appender = ( Appender < E > ) OptionHelper . instantiateByClassName ( className , ch . qos . logback . core . Appender . class , context ) ; appender . setContext ( context ) ; String appenderName = ec . subst ( attributes . getValue ( NAME_ATTRIBUTE ) ) ; 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 < E > > appenderBag = ( HashMap < String , Appender < E > > ) 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 ) ; } }
Instantiates an appender of the given class and sets its name .