public void setMailLog ( String logFile , String level ) throws PageException { checkWriteAccess ( ) ; boolean hasAccess = ConfigWebUtil . hasAccess ( config , SecurityManager . TYPE_MAIL ) ; if ( ! hasAccess ) throw new SecurityException ( "no access to update mail server settings" ) ; ConfigWebUtil . getFile ( config , config . getRootDirectory ( ) , logFile , FileUtil . TYPE_FILE ) ; Element logging = XMLConfigWebFactory . getChildByName ( doc . getDocumentElement ( ) , "logging" ) ; Element [ ] children = XMLUtil . getChildElementsAsArray ( logging ) ; Element logger = null ; for ( int i = 0 ; i < children . length ; i ++ ) { if ( children [ i ] . getTagName ( ) . equals ( "logger" ) && "mail" . equalsIgnoreCase ( children [ i ] . getAttribute ( "name" ) ) ) { logger = children [ i ] ; break ; } } if ( logger == null ) { logger = doc . createElement ( "logger" ) ; logging . appendChild ( logger ) ; } logger . setAttribute ( "name" , "mail" ) ; if ( "console" . equalsIgnoreCase ( logFile ) ) { setClass ( logger , null , "appender-" , Log4jUtil . appenderClassDefintion ( "console" ) ) ; setClass ( logger , null , "layout-" , Log4jUtil . layoutClassDefintion ( "pattern" ) ) ; } else { setClass ( logger , null , "appender-" , Log4jUtil . appenderClassDefintion ( "resource" ) ) ; setClass ( logger , null , "layout-" , Log4jUtil . layoutClassDefintion ( "classic" ) ) ; logger . setAttribute ( "appender-arguments" , "path:" + logFile ) ; } logger . setAttribute ( "log-level" , level ) ; }
sets Mail Logger to Config