FileDocCategorySizeDatePackage
LogLevelChangeEventListenerImpl.javaAPI DocGlassfish v2 API4752Fri May 04 22:35:44 BST 2007com.sun.enterprise.server.logging

LogLevelChangeEventListenerImpl

public class LogLevelChangeEventListenerImpl extends Object implements com.sun.enterprise.admin.event.LogLevelChangeEventListener

Fields Summary
Constructors Summary
Methods Summary
public voidlogLevelChanged(com.sun.enterprise.admin.event.LogLevelChangeEvent event)

        try {
            if( event.isPropertyChanged() ) {
                ConfigContext newConfig = event.getConfigContext();                
                Iterator iter = event.getConfigChangeList().iterator();
                while (iter.hasNext() )  {
                    Object change= iter.next();
                    if (change instanceof ConfigAdd || change instanceof ConfigUpdate) {
                        String xpath = ((ConfigChange)change).getXPath();
                        if( xpath != null){
                            ConfigBean item = newConfig.exactLookup(xpath); 
                            if (item instanceof ElementProperty) {
                                ElementProperty elementProperty = (ElementProperty)item;
                                String loggerName  = elementProperty.getName();
                                String logLevel    = elementProperty.getValue();
                                boolean logExists = LogMBean.getInstance().findLogger(loggerName);
                                if (!logExists) {
                                    Logger.getLogger(loggerName);  //if the logger doesn't exist, create it.
				}        
                                LogMBean.getInstance().setLogLevel( loggerName, logLevel );
                            }
                        }
                    }
                }
            } else {
                // This is not a property change event, so it must be a 
                // module log level change.
                LogMBean.getInstance().setLogLevelForModule(
                    event.getModuleName(), event.getNewLogLevel() );
            }
        } catch( Exception e ) {
            new ErrorManager().error( "Error In LogLevelChanged event", e,
                ErrorManager.GENERIC_FAILURE );
        }