1 23 24 package com.sun.enterprise.server.logging; 25 26 import java.util.logging.ErrorManager ; 27 import java.util.logging.Level ; 28 import java.util.logging.Logger ; 29 import java.util.List ; 30 import java.util.ArrayList ; 31 import java.util.Iterator ; 32 33 import com.sun.enterprise.admin.event.LogLevelChangeEventListener; 34 import com.sun.enterprise.admin.event.LogLevelChangeEvent; 35 import com.sun.enterprise.admin.event.AdminEventListenerRegistry; 36 import com.sun.enterprise.admin.event.AdminEventListenerException; 37 import com.sun.enterprise.config.serverbeans.ElementProperty; 38 import com.sun.enterprise.config.ConfigContext; 39 import com.sun.enterprise.config.ConfigBean; 40 import com.sun.enterprise.config.ConfigChange; 41 import com.sun.enterprise.config.ConfigAdd; 42 import com.sun.enterprise.config.ConfigUpdate; 43 44 public class LogLevelChangeEventListenerImpl 45 implements LogLevelChangeEventListener 46 { 47 public void logLevelChanged(LogLevelChangeEvent event) 48 throws AdminEventListenerException 49 { 50 try { 51 if( event.isPropertyChanged() ) { 52 ConfigContext newConfig = event.getConfigContext(); 53 Iterator iter = event.getConfigChangeList().iterator(); 54 while (iter.hasNext() ) { 55 Object change= iter.next(); 56 if (change instanceof ConfigAdd || change instanceof ConfigUpdate) { 57 String xpath = ((ConfigChange)change).getXPath(); 58 if( xpath != null){ 59 ConfigBean item = newConfig.exactLookup(xpath); 60 if (item instanceof ElementProperty) { 61 ElementProperty elementProperty = (ElementProperty)item; 62 String loggerName = elementProperty.getName(); 63 String logLevel = elementProperty.getValue(); 64 boolean logExists = LogMBean.getInstance().findLogger(loggerName); 65 if (!logExists) { 66 Logger.getLogger(loggerName); } 68 LogMBean.getInstance().setLogLevel( loggerName, logLevel ); 69 } 70 } 71 } 72 } 73 } else { 74 LogMBean.getInstance().setLogLevelForModule( 77 event.getModuleName(), event.getNewLogLevel() ); 78 } 79 } catch( Exception e ) { 80 new ErrorManager ().error( "Error In LogLevelChanged event", e, 81 ErrorManager.GENERIC_FAILURE ); 82 } 83 } 84 } 85 | Popular Tags |