tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/juli/src/java/org/apache/juli ClassLoaderLogManager.java FileHandler.java
Date Wed, 02 Mar 2005 21:40:00 GMT
remm        2005/03/02 13:40:00

  Modified:    juli/src/java/org/apache/juli ClassLoaderLogManager.java
                        FileHandler.java
  Log:
  - The java.util.logging javadocs imply that the configuration of the handler (filter, formatter,
etc) should be done by the handler itself.
  
  Revision  Changes    Path
  1.2       +30 -3     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ClassLoaderLogManager.java	2 Mar 2005 18:30:45 -0000	1.1
  +++ ClassLoaderLogManager.java	2 Mar 2005 21:40:00 -0000	1.2
  @@ -16,13 +16,23 @@
   
   package org.apache.juli;
   
  -import java.util.logging.*;
  -import java.util.*;
   import java.io.IOException;
   import java.io.InputStream;
   import java.net.URLClassLoader;
   import java.security.AccessController;
   import java.security.PrivilegedAction;
  +import java.util.Collections;
  +import java.util.Enumeration;
  +import java.util.HashMap;
  +import java.util.Iterator;
  +import java.util.Map;
  +import java.util.Properties;
  +import java.util.StringTokenizer;
  +import java.util.WeakHashMap;
  +import java.util.logging.Handler;
  +import java.util.logging.Level;
  +import java.util.logging.LogManager;
  +import java.util.logging.Logger;
   
   
   /**
  @@ -294,12 +304,29 @@
                               this.prefix.set(prefix);
                               Handler handler = 
                                   (Handler) classLoader.loadClass(handlerClassName).newInstance();
  -                            this.prefix.set(null);
  +                            // FIXME: The specification strongly implies this should be
done in the
  +                            // handler configuration
  +                            /*
  +                            // Initialize handler's level
                               String handlerLevel = 
                                   info.props.getProperty(handlerName + ".level");
                               if (handlerLevel != null) {
                                   handler.setLevel(Level.parse(handlerLevel.trim()));
                               }
  +                            // Initialize filter
  +                            String filterName =
  +                                info.props.getProperty(handlerName + ".filter");
  +                            if (filterName != null) {
  +                                try {
  +                                    handler.setFilter
  +                                        ((Filter) classLoader.loadClass(filterName).newInstance());
  +                                } catch (Exception e) {
  +                                    // FIXME: Report this using the main logger ?
  +                                    // Ignore
  +                                }
  +                            }
  +                            */
  +                            this.prefix.set(null);
                               info.handlers.put(handlerName, handler);
                               if (rootHandlers == null) {
                                   localRootLogger.addHandler(handler);
  
  
  
  1.2       +37 -8     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FileHandler.java	2 Mar 2005 18:30:45 -0000	1.1
  +++ FileHandler.java	2 Mar 2005 21:40:00 -0000	1.2
  @@ -23,7 +23,10 @@
   import java.io.UnsupportedEncodingException;
   import java.sql.Timestamp;
   import java.util.logging.ErrorManager;
  +import java.util.logging.Filter;
  +import java.util.logging.Formatter;
   import java.util.logging.Handler;
  +import java.util.logging.Level;
   import java.util.logging.LogManager;
   import java.util.logging.LogRecord;
   import java.util.logging.SimpleFormatter;
  @@ -238,27 +241,53 @@
           LogManager manager = LogManager.getLogManager();
           String className = FileHandler.class.getName();
           
  +        ClassLoader cl = Thread.currentThread().getContextClassLoader();
  +        
           // Retrieve configuration of logging file name
           directory = getProperty(className + ".directory", "logs");
           prefix = getProperty(className + ".prefix", "juli.");
           suffix = getProperty(className + ".suffix", ".log");
   
  -        // FIXME: Add filter configuration in LogManager ?
  -        //setFilter(manager.getFilterProperty(className + ".filter", null));
  -        // FIXME: Add formatter configuration in LogManager ?
  -        //setFormatter(manager.getFormatterProperty(className + ".formatter", new SimpleFormatter()));
  -        // Hardcode for now a SimpleFormatter
  -        setFormatter(new SimpleFormatter());
  -        // FIXME: Add encoding configuration in LogManager ?
  +        // FIXME: This should IMO be shared at the LogManager level, but the javadocs
  +        // seem to imply that this should not be the case for some reason
  +        
  +        // Get logging level for the handler
  +        setLevel(Level.parse(getProperty(className + ".level", "" + Level.ALL)));
  +
  +        // Get filter configuration
  +        String filterName = getProperty(className + ".filter", null);
  +        if (filterName != null) {
  +            try {
  +                setFilter((Filter) cl.loadClass(filterName).newInstance());
  +            } catch (Exception e) {
  +                // Ignore
  +            }
  +        }
  +
  +        // Set formatter
  +        String formatterName = getProperty(className + ".formatter", null);
  +        if (formatterName != null) {
  +            try {
  +                setFormatter((Formatter) cl.loadClass(formatterName).newInstance());
  +            } catch (Exception e) {
  +                // Ignore
  +            }
  +        } else {
  +            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: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message