Index: common/common-util/src/main/java/com/sun/common/util/logging/LoggingConfig.java =================================================================== --- common/common-util/src/main/java/com/sun/common/util/logging/LoggingConfig.java (revision 47132) +++ common/common-util/src/main/java/com/sun/common/util/logging/LoggingConfig.java (working copy) @@ -44,7 +44,6 @@ import java.io.IOException; import java.util.Map; -import java.util.Set; /** * Interface for Logging Commands @@ -59,11 +58,13 @@ /* set propertyName to be propertyValue. The logManager * readConfiguration is not called in this method. */ + String setLoggingProperty(String propertyName, String propertyValue) throws IOException; /* set propertyName to be propertyValue. The logManager * readConfiguration is not called in this method. */ + String setLoggingProperty(String propertyName, String propertyValue, String targetServer) throws IOException; /* update the properties to new values. properties is a Map of names of properties and @@ -72,6 +73,7 @@ * * The readConfiguration method is called on the logManager after updating the properties. */ + Map updateLoggingProperties(Map properties) throws IOException; /* update the properties to new values for given target server.. properties is a Map of names of properties and @@ -80,22 +82,32 @@ * * The readConfiguration method is called on the logManager after updating the properties. */ + Map updateLoggingProperties(Map properties, String targetServer) throws IOException; /* get the properties and corresponding values in the logging.properties file for given target server.. */ + Map getLoggingProperties(String targetServer) throws IOException; /* get the properties and corresponding values in the logging.properties file. */ + Map getLoggingProperties() throws IOException; - /* remove a set of properties from the logging.properties file. + /* creates zip file for given sourceDirectory */ - void removeLoggingProperties(Set properties) throws IOException; - /* creates zip file for given sourceDirectory - */ String createZipFile(String sourceDir) throws IOException; + /* delete the properties from logging.properties file for given target. + */ + + public void deleteLoggingProperties(Map properties, String targetConfigName) throws IOException; + + /* delete the properties from logging.properties file. + */ + + public void deleteLoggingProperties(Map properties) throws IOException; + } Index: common/common-util/src/main/java/com/sun/common/util/logging/LoggingConfigImpl.java =================================================================== --- common/common-util/src/main/java/com/sun/common/util/logging/LoggingConfigImpl.java (revision 47132) +++ common/common-util/src/main/java/com/sun/common/util/logging/LoggingConfigImpl.java (working copy) @@ -397,42 +397,59 @@ } } - /* - * remove the listed properties from the logging.properties file. - * The readConfiguration method is called on the logManager after updating the properties. + /* delete the properties from logging.properties file. properties is a Map of names of properties and + * their cooresponding value. + * + * @param properties Map of the name and value of property to delete * - * @param properties Set of the names of properties to remove - * * @throws IOException */ - public void removeLoggingProperties(Set properties) throws IOException { + public void deleteLoggingProperties(Map properties) throws IOException { try { openPropFile(); - Iterator i = properties.iterator(); - while (i.hasNext()) { - try { - Object p = i.next(); - logger.log(Level.FINER, "Remove from logging.properties file property ", p); - - props.remove((String) p); - } catch (java.util.NoSuchElementException e) { - //System.out.println("Attempt to remove nonexistent property "+e); - Logger.getAnonymousLogger().log(Level.WARNING, "Attempt to remove nonexistent property ", e); - // continue; + // need to map the name given to the new name in logging.properties file + String key = null; + for (Map.Entry e : properties.entrySet()) { + key = LoggingXMLNames.xmltoPropsMap.get(e.getKey()); + if (key == null) { + key = e.getKey(); } + props.remove(key); } + closePropFile(); + } catch (Exception e) { + // e.printStackTrace(); + } + } - try { - logMgr.readConfiguration(); - } catch (java.io.IOException e) { - Logger.getAnonymousLogger().log(Level.SEVERE, "Cannot reconfigure LogManager : ", e); - throw new IOException(); + /* delete the properties from logging.properties file for given target. properties is a Map of names of properties and + * their cooresponding value. + * + * @param properties Map of the name and value of property to delete + * + * @throws IOException + */ + + public void deleteLoggingProperties(Map properties, String targetConfigName) throws IOException { + try { + openPropFile(targetConfigName); + + // need to map the name given to the new name in logging.properties file + String key = null; + for (Map.Entry e : properties.entrySet()) { + key = LoggingXMLNames.xmltoPropsMap.get(e.getKey()); + if (key == null) { + key = e.getKey(); + } + props.remove(key); } - } catch (IOException ex) { - throw ex; + + closePropFile(); + } catch (Exception e) { + // e.printStackTrace(); } } @@ -614,4 +631,32 @@ return null; } + /* Return a Map of all the properties and corresponding values from the logging.properties file from template.. + * @throws IOException + */ + + public Map getDefaultLoggingProperties() throws IOException { + Map m = new HashMap(); + String rootFolder = env.getProps().get(com.sun.enterprise.util.SystemPropertyConstants.INSTALL_ROOT_PROPERTY); + String templateDir = rootFolder + File.separator + "lib" + File.separator + "templates"; + File loggingTemplateFile = new File(templateDir, ServerEnvironmentImpl.kLoggingPropertiesFileName); + + Properties propsLoggingTempleate = new Properties(); + FileInputStream fisForLoggingTemplate = new java.io.FileInputStream(loggingTemplateFile); + propsLoggingTempleate.load(fisForLoggingTemplate); + fisForLoggingTemplate.close(); + + Enumeration e = propsLoggingTempleate.propertyNames(); + + while (e.hasMoreElements()) { + String key = (String) e.nextElement(); + // convert the name in domain.xml to the name in logging.properties if needed + if (LoggingXMLNames.xmltoPropsMap.get(key) != null) { + key = LoggingXMLNames.xmltoPropsMap.get(key); + } + m.put(key, propsLoggingTempleate.getProperty(key)); + } + return m; + } + }