Steven.Shaw | 1 Sep 2003 01:35
Picon

RE: ConfigureAndWatch with Webwork

Take a look at the properties "log4j.configuration" and "log4j.configuratorClass". There's a bit of information in the short manual
http://jakarta.apache.org/log4j/docs/manual.html (where it uses them to set of Tomcat options).
 
Then using something like this:
 
    java -Dlog4j.configuration="log4.xml" -Dlog4j.configuratorClass=au.com.foo.util.log.ConfigureAndWatchConfigurator
 
Something like the following works for me:
 
...
public class ConfigureAndWatchConfigurator implements Configurator {
    public void doConfigure(URL url, LoggerRepository repository) {
        long watchDelaySeconds = 30;
        DOMConfigurator.configureAndWatch(url.getPath(), watchDelaySeconds * 1000);
 
        org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(getClass());
        logger.info("log4j configured using " + url);
        logger.info("log4j watch-delay is " + watchDelaySeconds + "s");
    }
}
Steve.
 
-----Original Message-----
From: Rajat Sharma [mailto:rajat_stuff <at> yahoo.com]
Sent: Saturday, 30 August 2003 3:27 AM
To: log4j-dev <at> jakarta.apache.org
Subject: ConfigureAndWatch with Webwork

Hi
 
I've just started using Log4J and had a couple of doubts about how to set it up for a web-based application that uses Webwork.
 
1. Since Webwork configures log4j to use Configure, is there any way that can be changed to ConfigureAndWatch, without going into Webwork code.
2. Since there are multiple entry-points for the application, where should I specify the Configurator details (essentially, the ConfigureAndWatch method call)
 
thanks a lot
Rajat.

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
psmith | 1 Sep 2003 03:59
Picon
Favicon

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggerNameListener.java

psmith      2003/08/31 18:59:19

  Modified:    src/java/org/apache/log4j/chainsaw LoggerNameListener.java
  Log:
  For consistency, this Listener interface should extend
  from EventListener interface (and the swing EventListenerList
  support/delegate class requires this, handy for marking anyway).

  Revision  Changes    Path
  1.2       +3 -1      jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggerNameListener.java

  Index: LoggerNameListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggerNameListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LoggerNameListener.java	29 Aug 2003 05:53:36 -0000	1.1
  +++ LoggerNameListener.java	1 Sep 2003 01:59:19 -0000	1.2
   <at>  <at>  -49,6 +49,8  <at>  <at> 

   package org.apache.log4j.chainsaw;

  +import java.util.EventListener;
  +

   /**
    * Implementations are notified when new Logger names
   <at>  <at>  -56,7 +58,7  <at>  <at> 
    * 
    *  <at> author Paul Smith <psmith <at> apache.org>
    */
  -public interface LoggerNameListener {
  +public interface LoggerNameListener extends EventListener {
     /**
      * Called by LoggerNameModel instances when a new unique
      * Logger name string has been introduced into the model
psmith | 1 Sep 2003 04:00
Picon
Favicon

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggerNameModelSupport.java

psmith      2003/08/31 19:00:19

  Added:       src/java/org/apache/log4j/chainsaw
                        LoggerNameModelSupport.java
  Log:
  Additional support/delegate class to handle the work
  load of the LoggerNameModel.  Other class that
  wish to implement the model interface but don't wish
  to burden themselves with the effort can delegate to this
  class.

  Revision  Changes    Path
  1.1                  jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggerNameModelSupport.java

  Index: LoggerNameModelSupport.java
  ===================================================================
  /*
   * ============================================================================
   *                   The Apache Software License, Version 1.1
   * ============================================================================
   *
   *    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without modifica-
   * tion, are permitted provided that the following conditions are met:
   *
   * 1. Redistributions of  source code must  retain the above copyright  notice,
   *    this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright notice,
   *    this list of conditions and the following disclaimer in the documentation
   *    and/or other materials provided with the distribution.
   *
   * 3. The end-user documentation included with the redistribution, if any, must
   *    include  the following  acknowledgment:  "This product includes  software
   *    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
   *    Alternately, this  acknowledgment may  appear in the software itself,  if
   *    and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "log4j" and  "Apache Software Foundation"  must not be used to
   *    endorse  or promote  products derived  from this  software without  prior
   *    written permission. For written permission, please contact
   *    apache <at> apache.org.
   *
   * 5. Products  derived from this software may not  be called "Apache", nor may
   *    "Apache" appear  in their name,  without prior written permission  of the
   *    Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   * APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   * DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   * OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   * ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   * (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * This software  consists of voluntary contributions made  by many individuals
   * on  behalf of the Apache Software  Foundation.  For more  information on the
   * Apache Software Foundation, please see <http://www.apache.org/>.
   *
   */

  /*
   */
  package org.apache.log4j.chainsaw;

  import java.util.Collection;
  import java.util.Collections;
  import java.util.HashSet;
  import java.util.Set;

  import javax.swing.event.EventListenerList;

  
  /**
   * An implementation of LoggerNameModel which can be used as a delegate
   * 
   *  <at> author Paul Smith <psmith <at> apache.org>
   */
  public class LoggerNameModelSupport implements LoggerNameModel {

    private Set loggerNameSet = new HashSet();
    private EventListenerList listenerList = new EventListenerList();

  
    /* (non-Javadoc)
     *  <at> see org.apache.log4j.chainsaw.LoggerNameModel#getLoggerNames()
     */
    public Collection getLoggerNames() {
      return Collections.unmodifiableSet(loggerNameSet);
    }

    /* (non-Javadoc)
     *  <at> see org.apache.log4j.chainsaw.LoggerNameModel#addLoggerName(java.lang.String)
     */
    public boolean addLoggerName(String loggerName) {
      boolean isNew = loggerNameSet.add(loggerName);

      if(isNew)
      {
        notifyListeners(loggerName);
      }

      return isNew;
    }

    /**
     * Notifies all the registered listeners that a new unique
     * logger name has been added to this model
     *  <at> param loggerName
     */
    private void notifyListeners(String loggerName)
    {
      LoggerNameListener[] eventListeners = (LoggerNameListener[]) listenerList.getListeners(LoggerNameListener.class);

      for (int i = 0; i < eventListeners.length; i++)
      {
        LoggerNameListener listener = eventListeners[i];
        listener.loggerNameAdded(loggerName);
      }    
    }

    /* (non-Javadoc)
     *  <at> see org.apache.log4j.chainsaw.LoggerNameModel#addLoggerNameListener(org.apache.log4j.chainsaw.LoggerNameListener)
     */
    public void addLoggerNameListener(LoggerNameListener l) {
      listenerList.add(LoggerNameListener.class, l);
    }

    /* (non-Javadoc)
     *  <at> see org.apache.log4j.chainsaw.LoggerNameModel#removeLoggerNameListener(org.apache.log4j.chainsaw.LoggerNameListener)
     */
    public void removeLoggerNameListener(LoggerNameListener l) {
      listenerList.remove(LoggerNameListener.class, l);
    }
  }
psmith | 1 Sep 2003 04:01
Picon
Favicon

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggerNameModel.java

psmith      2003/08/31 19:01:05

  Modified:    src/java/org/apache/log4j/chainsaw LoggerNameModel.java
  Log:
  added the all important addLoggerName method
  which is called when a new Logger name should
  be added to this model.

  Revision  Changes    Path
  1.2       +12 -0     jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggerNameModel.java

  Index: LoggerNameModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggerNameModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LoggerNameModel.java	29 Aug 2003 05:53:36 -0000	1.1
  +++ LoggerNameModel.java	1 Sep 2003 02:01:05 -0000	1.2
   <at>  <at>  -70,6 +70,18  <at>  <at> 
      */
     public Collection getLoggerNames();

  +  /**
  +   * Attempts to add the loggerName to the model, and returns
  +   * true if it does, i.e that the loggerName is new, otherwise
  +   * it is ignored.
  +   * 
  +   * If the loggerName is new for this model, all the LoggerNameListeners
  +   * are notified using this thread.
  +   * 
  +   *  <at> param loggerName
  +   */
  +  public boolean addLoggerName(String loggerName);
  +  
     public void addLoggerNameListener(LoggerNameListener l);
     public void removeLoggerNameListener(LoggerNameListener l);
   }
psmith | 1 Sep 2003 04:02
Picon
Favicon

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LogPanelLoggerTreeModel.java

psmith      2003/08/31 19:02:32

  Modified:    src/java/org/apache/log4j/chainsaw
                        LogPanelLoggerTreeModel.java
  Log:
  more effecient notification of the addition of nodes.

  The original method sent a nodeStructureChanged msg
  but this is pretty expensive, and tends to have the side
  effect of the Tree gui's constantly collapsing the icons.

  This model now notifies in the Swing event dispatching
  thread, and notifies each additional logger name node.

  Revision  Changes    Path
  1.2       +13 -8     jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogPanelLoggerTreeModel.java

  Index: LogPanelLoggerTreeModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogPanelLoggerTreeModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LogPanelLoggerTreeModel.java	29 Aug 2003 05:53:36 -0000	1.1
  +++ LogPanelLoggerTreeModel.java	1 Sep 2003 02:02:32 -0000	1.2
   <at>  <at>  -73,14 +73,8  <at>  <at> 
    */
   class LogPanelLoggerTreeModel extends DefaultTreeModel
     implements LoggerNameListener {
  -  private LogUI.LogPanel logPanel;

  -  LogPanelLoggerTreeModel(LogUI.LogPanel logPanel) {
  -    this();
  -    this.logPanel = logPanel;
  -  }
  -
  -  private LogPanelLoggerTreeModel() {
  +  LogPanelLoggerTreeModel() {
       super(new DefaultMutableTreeNode("Root"));
     }

   <at>  <at>  -133,10 +127,21  <at>  <at> 
         DefaultMutableTreeNode newChild =
           new DefaultMutableTreeNode(packageName);
         current.add(newChild);
  +      
  +      final TreeNode changedNode = current;
  +      final int[] changedIndices = new int[]{current.getIndex(newChild)};
  +      SwingUtilities.invokeLater(new Runnable(){
  +
  +        public void run()
  +        {
  +          nodesWereInserted(changedNode, changedIndices);
  +          
  +        }});
         current = newChild;
       }

  -    nodeStructureChanged((TreeNode) getRoot());
  +    
  +//    nodeStructureChanged((TreeNode) getRoot());

     }
psmith | 1 Sep 2003 04:03
Picon
Favicon

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw ChainsawCyclicBufferTableModel.java EventContainer.java

psmith      2003/08/31 19:03:03

  Modified:    src/java/org/apache/log4j/chainsaw
                        ChainsawCyclicBufferTableModel.java
                        EventContainer.java
  Log:
  EventContainer now extends the LoggerNameModel interface
  and simply delegates it to the support class.

  Revision  Changes    Path
  1.2       +60 -0     jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java

  Index: ChainsawCyclicBufferTableModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChainsawCyclicBufferTableModel.java	25 Jun 2003 04:05:21 -0000	1.1
  +++ ChainsawCyclicBufferTableModel.java	1 Sep 2003 02:03:03 -0000	1.2
   <at>  <at>  -59,6 +59,7  <at>  <at> 
   import java.text.ParseException;
   import java.text.SimpleDateFormat;
   import java.util.ArrayList;
  +import java.util.Collection;
   import java.util.Collections;
   import java.util.Hashtable;
   import java.util.Iterator;
   <at>  <at>  -101,9 +102,68  <at>  <at> 
     private boolean sortEnabled = false;
     protected final Object syncLock = new Object();

  +  private LoggerNameModel loggerNameModelDelegate = new LoggerNameModelSupport();
  +  
     //because we may be using a cyclic buffer, if an ID is not provided in the property, 
     //use and increment this row counter as the ID for each received row
     int uniqueRow;
  +
  +  /**
  +   *  <at> param l
  +   */
  +  public void removeLoggerNameListener(LoggerNameListener l)
  +  {
  +    loggerNameModelDelegate.removeLoggerNameListener(l);
  +  }
  +
  +  /* (non-Javadoc)
  +   *  <at> see java.lang.Object#hashCode()
  +   */
  +  public int hashCode()
  +  {
  +    return loggerNameModelDelegate.hashCode();
  +  }
  +
  +  /**
  +   *  <at> param loggerName
  +   *  <at> return
  +   */
  +  public boolean addLoggerName(String loggerName)
  +  {
  +    return loggerNameModelDelegate.addLoggerName(loggerName);
  +  }
  +
  +  /* (non-Javadoc)
  +   *  <at> see java.lang.Object#toString()
  +   */
  +  public String toString()
  +  {
  +    return loggerNameModelDelegate.toString();
  +  }
  +
  +  /**
  +   *  <at> param l
  +   */
  +  public void addLoggerNameListener(LoggerNameListener l)
  +  {
  +    loggerNameModelDelegate.addLoggerNameListener(l);
  +  }
  +
  +  /**
  +   *  <at> return
  +   */
  +  public Collection getLoggerNames()
  +  {
  +    return loggerNameModelDelegate.getLoggerNames();
  +  }
  +
  +  /* (non-Javadoc)
  +   *  <at> see java.lang.Object#equals(java.lang.Object)
  +   */
  +  public boolean equals(Object obj)
  +  {
  +    return loggerNameModelDelegate.equals(obj);
  +  }

     public ChainsawCyclicBufferTableModel(boolean isCyclic, int bufferSize) {
       this.cyclic = isCyclic;

  

  1.3       +1 -1      jakarta-log4j/src/java/org/apache/log4j/chainsaw/EventContainer.java

  Index: EventContainer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/EventContainer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EventContainer.java	23 Aug 2003 16:00:52 -0000	1.2
  +++ EventContainer.java	1 Sep 2003 02:03:03 -0000	1.3
   <at>  <at>  -60,7 +60,7  <at>  <at> 
    *  <at> author Scott Deboy <sdeboy <at> apache.org>
    * 
    */
  -public interface EventContainer extends SortTableModel, FilterChangedListener {
  +public interface EventContainer extends SortTableModel, FilterChangedListener, LoggerNameModel {
     /**
      * Adds an EventCountListener, to be notified when the # of events changes
      *  <at> param listener
psmith | 1 Sep 2003 04:03
Picon
Favicon

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggerNameTree.java

psmith      2003/08/31 19:03:30

  Added:       src/java/org/apache/log4j/chainsaw LoggerNameTree.java
  Log:
  New Tree component that that is used for Logger names.

  Revision  Changes    Path
  1.1                  jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggerNameTree.java

  Index: LoggerNameTree.java
  ===================================================================
  /*
   * ============================================================================
   *                   The Apache Software License, Version 1.1
   * ============================================================================
   *
   *    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without modifica-
   * tion, are permitted provided that the following conditions are met:
   *
   * 1. Redistributions of  source code must  retain the above copyright  notice,
   *    this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright notice,
   *    this list of conditions and the following disclaimer in the documentation
   *    and/or other materials provided with the distribution.
   *
   * 3. The end-user documentation included with the redistribution, if any, must
   *    include  the following  acknowledgment:  "This product includes  software
   *    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
   *    Alternately, this  acknowledgment may  appear in the software itself,  if
   *    and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "log4j" and  "Apache Software Foundation"  must not be used to
   *    endorse  or promote  products derived  from this  software without  prior
   *    written permission. For written permission, please contact
   *    apache <at> apache.org.
   *
   * 5. Products  derived from this software may not  be called "Apache", nor may
   *    "Apache" appear  in their name,  without prior written permission  of the
   *    Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   * APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   * DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   * OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   * ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   * (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * This software  consists of voluntary contributions made  by many individuals
   * on  behalf of the Apache Software  Foundation.  For more  information on the
   * Apache Software Foundation, please see <http://www.apache.org/>.
   *
   */

  /*
   */
  package org.apache.log4j.chainsaw;

  import java.awt.Dimension;

  import javax.swing.JTree;
  import javax.swing.event.TreeModelEvent;
  import javax.swing.event.TreeModelListener;
  import javax.swing.tree.DefaultMutableTreeNode;
  import javax.swing.tree.DefaultTreeCellRenderer;
  import javax.swing.tree.TreeModel;

  
  /**
   * LoggerNameTree is used to display a TreeModel of LoggerNames.
   * 
   *  <at> author Paul Smith <psmith <at> apache.org>
   */
  public class LoggerNameTree extends JTree {
    LoggerNameTree(TreeModel model) {
      super(model);
      setPreferredSize(new Dimension(320, 240));

      //    ============================================
      //    TODO remove this WIP node once we're statisfied
      DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();

      DefaultMutableTreeNode node =
        new DefaultMutableTreeNode("Work in Progress...");
      node.setAllowsChildren(false);

      root.add(node);

      //  ============================================
      model.addTreeModelListener(
        new TreeModelListener() {
          public void treeNodesChanged(TreeModelEvent e) {
            ensureRootExpanded();
          }

          public void treeNodesInserted(TreeModelEvent e) {
            ensureRootExpanded();
          }

          public void treeNodesRemoved(TreeModelEvent e) {
            ensureRootExpanded();
          }

          private void ensureRootExpanded() {
            expandRow(0);
          }

          public void treeStructureChanged(TreeModelEvent e) {
            ensureRootExpanded();
          }
        });

      setEditable(false);

      setCellRenderer(new LoggerNameTreeCellRenderer());
    }

    /**
     * 
     *  <at> author Paul Smith <psmith <at> apache.org>
     *
     */
    private static class LoggerNameTreeCellRenderer
      extends DefaultTreeCellRenderer {
      private LoggerNameTreeCellRenderer() {
        super();
        setLeafIcon(getDefaultOpenIcon());

        //      setClosedIcon(null);
        //      setOpenIcon(null);
      }
    }
  }
psmith | 1 Sep 2003 04:07
Picon
Favicon

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LogUI.java

psmith      2003/08/31 19:07:14

  Modified:    src/java/org/apache/log4j/chainsaw LogUI.java
  Log:
  Table model is notified of new logger/category names arriving in the batch.

  LogPanel now contains a new JTree component that
  sits to the West of the Events panel, sizeable via a Split Pane and
  scroll bar.

  As of this version the tree does nothing but display
  the Logger hierarchy in tree form, with no functionality
  but Right click popup menu is coming to set levels, filters etc.

  Right now I am not 100% certain whether it should stay
  where it is sittingbut regardless the component
  should be used somewhere (another thought is
  in the Preferences area).

  IMHO, I think it's useful where it sits, but any feedback appreciated.

  Revision  Changes    Path
  1.9       +31 -7     jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java

  Index: LogUI.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LogUI.java	28 Aug 2003 05:39:04 -0000	1.8
  +++ LogUI.java	1 Sep 2003 02:07:14 -0000	1.9
   <at>  <at>  -139,6 +139,7  <at>  <at> 
   import javax.swing.JTable;
   import javax.swing.JTextField;
   import javax.swing.JToolBar;
  +import javax.swing.JTree;
   import javax.swing.JWindow;
   import javax.swing.KeyStroke;
   import javax.swing.ListSelectionModel;
   <at>  <at>  -153,6 +154,8  <at>  <at> 
   import javax.swing.event.ListSelectionListener;
   import javax.swing.event.TableColumnModelEvent;
   import javax.swing.event.TableColumnModelListener;
  +import javax.swing.event.TreeModelEvent;
  +import javax.swing.event.TreeModelListener;
   import javax.swing.table.AbstractTableModel;
   import javax.swing.table.TableColumn;
   import javax.swing.table.TableColumnModel;
   <at>  <at>  -1219,10 +1222,17  <at>  <at> 

         //also add it to the unique values list
         ((Set) map.get(ChainsawConstants.LEVEL_COL_NAME)).add(level);
  -      ((Set) map.get(ChainsawConstants.LOGGER_COL_NAME)).add(
  -        v.get(
  -          ChainsawColumns.getColumnsNames().indexOf(
  -            ChainsawConstants.LOGGER_COL_NAME)));
  +      Object loggerName = v.get(
  +        ChainsawColumns.getColumnsNames().indexOf(
  +          ChainsawConstants.LOGGER_COL_NAME));
  +      ((Set) map.get(ChainsawConstants.LOGGER_COL_NAME)).add(loggerName);
  +      
  +      
  +      /**
  +       * EventContainer is a LoggerNameModel imp, use that for notifing
  +       */
  +      tableModel.addLoggerName(loggerName.toString());
  +      
         ((Set) map.get(ChainsawConstants.THREAD_COL_NAME)).add(
           v.get(
             ChainsawColumns.getColumnsNames().indexOf(
   <at>  <at>  -1348,7 +1358,7  <at>  <at> 
       Set fileSet = new HashSet();
       Set levelSet = new HashSet();
       ScrollToBottom scrollToBottom;
  -
  +    private final LogPanelLoggerTreeModel logTreeModel = new LogPanelLoggerTreeModel();
       //used for consistency - stays empty - used to allow none set in the colordisplay selector and right click
       Set noneSet = new HashSet();
       Point currentPoint;
   <at>  <at>  -1361,6 +1371,9  <at>  <at> 
         this.scrollToBottom = scrollToBottom;
         this.tableModel = tableModel;
         this.table = table;
  +      
  +      tableModel.addLoggerNameListener(logTreeModel);
  +      
         levelSet = new HashSet((List) levelMap.get(eventType));
         map.put(ChainsawConstants.LEVEL_COL_NAME, levelSet);

   <at>  <at>  -1648,6 +1661,9  <at>  <at> 
         statusLabelPanel.add(upperPanel, BorderLayout.CENTER);
         eventsAndStatusPanel.add(statusLabelPanel, BorderLayout.NORTH);

  +      final JTree logTree = new LoggerNameTree(logTreeModel);
  +      final JScrollPane logTreeScroll = new JScrollPane(logTree);
  +      
         final JPanel detailPanel = new JPanel(new BorderLayout());

         //set valueisadjusting if holding down a key - don't process setdetail events
   <at>  <at>  -1691,8 +1707,16  <at>  <at> 
             }
           });

  -      //      add(upperPanel, BorderLayout.NORTH);
  -      add(lowerPanel, BorderLayout.CENTER);
  +
  +      JSplitPane nameTreeAndMainPanelSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
  +      nameTreeAndMainPanelSplit.add(logTreeScroll);
  +      nameTreeAndMainPanelSplit.add(lowerPanel);
  +      nameTreeAndMainPanelSplit.setOneTouchExpandable(true);
  +      nameTreeAndMainPanelSplit.setToolTipText("Still under development....");
  +      nameTreeAndMainPanelSplit.setDividerLocation(120);
  +      
  +      add(nameTreeAndMainPanelSplit, BorderLayout.CENTER);
  +//      add(lowerPanel, BorderLayout.CENTER);

         table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
psmith | 1 Sep 2003 05:56
Picon
Favicon

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LoggerNameTreePanel.java

psmith      2003/08/31 20:56:51

  Added:       src/java/org/apache/log4j/chainsaw LoggerNameTreePanel.java
  Log:
  Rather than encapsulate the Logger name tree in just
  a tree component, encapsulate it in a Panel so
  we can add some other functionality similar
  to the way the Receiver panel works (a mini-toolbar etc).

  Revision  Changes    Path
  1.1                  jakarta-log4j/src/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java

  Index: LoggerNameTreePanel.java
  ===================================================================
  /*
   * ============================================================================
   *                   The Apache Software License, Version 1.1
   * ============================================================================
   *
   *    Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without modifica-
   * tion, are permitted provided that the following conditions are met:
   *
   * 1. Redistributions of  source code must  retain the above copyright  notice,
   *    this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright notice,
   *    this list of conditions and the following disclaimer in the documentation
   *    and/or other materials provided with the distribution.
   *
   * 3. The end-user documentation included with the redistribution, if any, must
   *    include  the following  acknowledgment:  "This product includes  software
   *    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
   *    Alternately, this  acknowledgment may  appear in the software itself,  if
   *    and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "log4j" and  "Apache Software Foundation"  must not be used to
   *    endorse  or promote  products derived  from this  software without  prior
   *    written permission. For written permission, please contact
   *    apache <at> apache.org.
   *
   * 5. Products  derived from this software may not  be called "Apache", nor may
   *    "Apache" appear  in their name,  without prior written permission  of the
   *    Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   * APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   * DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   * OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   * ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   * (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * This software  consists of voluntary contributions made  by many individuals
   * on  behalf of the Apache Software  Foundation.  For more  information on the
   * Apache Software Foundation, please see <http://www.apache.org/>.
   *
   */

  /*
   */
  package org.apache.log4j.chainsaw;

  import java.awt.BorderLayout;

  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.JTree;

  
  /**
   *
   *  <at> author Paul Smith <psmith <at> apache.org>
   */
  final class LoggerNameTreePanel extends JPanel {

    final JTree logTree ;
    final JScrollPane scrollTree;
    /**
     *  <at> param logTreeModel
     */
    LoggerNameTreePanel(LogPanelLoggerTreeModel logTreeModel)
    {
      super(new BorderLayout());
      logTree = new LoggerNameTree(logTreeModel);

      scrollTree = new JScrollPane(logTree);
      add(scrollTree, BorderLayout.CENTER);
    }
  }
psmith | 1 Sep 2003 05:57
Picon
Favicon

cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LogPanelLoggerTreeModel.java

psmith      2003/08/31 20:57:33

  Modified:    src/java/org/apache/log4j/chainsaw
                        LogPanelLoggerTreeModel.java
  Log:
  Modified root tree node to say "Root Logger" (more logical).

  Removed commented out code.

  Revision  Changes    Path
  1.3       +1 -5      jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogPanelLoggerTreeModel.java

  Index: LogPanelLoggerTreeModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogPanelLoggerTreeModel.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LogPanelLoggerTreeModel.java	1 Sep 2003 02:02:32 -0000	1.2
  +++ LogPanelLoggerTreeModel.java	1 Sep 2003 03:57:33 -0000	1.3
   <at>  <at>  -75,7 +75,7  <at>  <at> 
     implements LoggerNameListener {

     LogPanelLoggerTreeModel() {
  -    super(new DefaultMutableTreeNode("Root"));
  +    super(new DefaultMutableTreeNode("Root Logger"));
     }

     /* (non-Javadoc)
   <at>  <at>  -139,10 +139,6  <at>  <at> 
           }});
         current = newChild;
       }
  -    
  -    
  -//    nodeStructureChanged((TreeNode) getRoot());
  -    
     }

     /**

Gmane