remm 2005/03/02 17:51:13 Modified: juli/src/java/org/apache/juli ClassLoaderLogManager.java FileHandler.java Log: - Implement delegation in getProperty (when the current classloader does not have any configuration). - Read useParentHandlers property. - Code cleanup in FileHandler. Revision Changes Path 1.4 +31 -5 jakarta-tomcat-connectors/juli/src/java/org/apache/juli/ClassLoaderLogManager.java Index: ClassLoaderLogManager.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/juli/src/java/org/apache/juli/ClassLoaderLogManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ClassLoaderLogManager.java 3 Mar 2005 00:23:00 -0000 1.3 +++ ClassLoaderLogManager.java 3 Mar 2005 01:51:12 -0000 1.4 @@ -159,6 +159,17 @@ } } } + + // Parse useParentHandlers to set if the logger should delegate to its parent. + // Unlike java.util.logging, the default is to not delegate if a list of handlers + // has been specified for the logger. + String useParentHandlersString = getProperty(loggerName + ".useParentHandlers"); + if ((useParentHandlersString != null) + && (!Boolean.valueOf(useParentHandlersString).booleanValue())) { + logger.setUseParentHandlers(false); + } else { + logger.setUseParentHandlers(true); + } return true; } @@ -216,11 +227,26 @@ } final ClassLoader classLoader = Thread.currentThread() .getContextClassLoader(); - String result = - getClassLoaderInfo(classLoader).props.getProperty(name); - if (result == null) { - // FIXME: Look in parent classloader ? Probably not. - result = super.getProperty(name); + ClassLoaderLogInfo info = getClassLoaderInfo(classLoader); + String result = info.props.getProperty(name); + // If the property was not found, and the current classloader had no + // configuration (property list is empty), look for the parent classloader + // properties. + if ((result == null) && (info.props.isEmpty())) { + ClassLoader current = classLoader.getParent(); + while (current != null) { + info = (ClassLoaderLogInfo) classLoaderLoggers.get(current); + if (info != null) { + result = info.props.getProperty(name); + if ((result != null) || (!info.props.isEmpty())) { + break; + } + } + current = current.getParent(); + } + if (result == null) { + result = super.getProperty(name); + } } // Simple property replacement (mostly for folder names) if (result != null) { 1.4 +11 -72 jakarta-tomcat-connectors/juli/src/java/org/apache/juli/FileHandler.java Index: FileHandler.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/juli/src/java/org/apache/juli/FileHandler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- FileHandler.java 3 Mar 2005 00:23:00 -0000 1.3 +++ FileHandler.java 3 Mar 2005 01:51:12 -0000 1.4 @@ -20,7 +20,6 @@ import java.io.File; import java.io.FileWriter; import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; import java.sql.Timestamp; import java.util.logging.ErrorManager; import java.util.logging.Filter; @@ -51,6 +50,14 @@ open(); } + + public FileHandler(String directory, String prefix, String suffix) { + this(); + this.directory = directory; + this.prefix = prefix; + this.suffix = suffix; + } + // ----------------------------------------------------- Instance Variables @@ -86,63 +93,6 @@ private PrintWriter writer = null; - // ------------------------------------------------------------- Properties - - - /** - * Return the directory in which we create log files. - public String getDirectory() { - return (directory); - } - */ - - - /** - * Set the directory in which we create log files. - * - * @param directory The new log file directory - public void setDirectory(String directory) { - this.directory = directory; - } - */ - - - /** - * Return the log file prefix. - public String getPrefix() { - return (prefix); - } - */ - - - /** - * Set the log file prefix. - * - * @param prefix The new log file prefix - public void setPrefix(String prefix) { - this.prefix = prefix; - } - */ - - - /** - * Return the log file suffix. - public String getSuffix() { - return (suffix); - } - */ - - - /** - * Set the log file suffix. - * - * @param suffix The new log file suffix - public void setSuffix(String suffix) { - this.suffix = suffix; - } - */ - - // --------------------------------------------------------- Public Methods @@ -196,7 +146,7 @@ /** - * Close the currently open log file (if any) + * Close the currently open log file (if any). */ public void close() { @@ -216,7 +166,7 @@ /** - * FLush + * Flush the writer. */ public void flush() { @@ -276,17 +226,6 @@ setFormatter(new SimpleFormatter()); } - // Set encoding - try { - setEncoding(manager.getProperty(className + ".encoding")); - } catch (UnsupportedEncodingException e) { - try { - setEncoding(null); - } catch (Exception ex) { - // Ignore - } - } - // Set error manager setErrorManager(new ErrorManager());
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]