logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r687241 - in /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw: LogUI.java receivers/ReceiversPanel.java vfs/VFSLogFilePatternReceiver.java
Date Wed, 20 Aug 2008 04:47:45 GMT
Author: sdeboy
Date: Tue Aug 19 21:47:45 2008
New Revision: 687241

URL: http://svn.apache.org/viewvc?rev=687241&view=rev
Log:
ensure all org.apache loggers used by chainsaw and plugins get routed to the chainsaw-log
tab

set vfs cache logger to info because debug-level logging can contain username/password

on receiver restart, provide visualreceivers with their needed container

remove vfslogfilepatternreceiver logging which could container username/password

improve vfslogfilepatternreceiver support for restarting the receiver

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.java

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java?rev=687241&r1=687240&r2=687241&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java Tue Aug 19 21:47:45
2008
@@ -334,7 +334,7 @@
     logUI.ensureChainsawAppenderHandlerAdded();
     logger = LogManager.getLogger(LogUI.class);
 
-    //set hostname & application properties which will cause Chainsaw-generated
+    //set hostname & application properties which will cause Chainsaw and other apache-generated
     //logging events to route (by default) to a tab named 'chainsaw-log'
     PropertyRewritePolicy policy = new PropertyRewritePolicy();
     policy.setProperties("hostname=chainsaw,application=log");
@@ -342,7 +342,7 @@
     RewriteAppender rewriteAppender = new RewriteAppender();
     rewriteAppender.setRewritePolicy(policy);
 
-    Enumeration appenders = Logger.getLogger("org.apache.log4j").getAllAppenders();
+    Enumeration appenders = Logger.getLogger("org.apache").getAllAppenders();
     if (!appenders.hasMoreElements()) {
     	appenders = Logger.getRootLogger().getAllAppenders();
     }
@@ -350,9 +350,11 @@
     	Appender nextAppender = (Appender)appenders.nextElement();
     	rewriteAppender.addAppender(nextAppender);
     }
-    Logger.getLogger("org.apache.log4j").removeAllAppenders();
-    Logger.getLogger("org.apache.log4j").addAppender(rewriteAppender);
-    Logger.getLogger("org.apache.log4j").setAdditivity(false);
+    Logger.getLogger("org.apache").removeAllAppenders();
+    Logger.getLogger("org.apache").addAppender(rewriteAppender);
+    Logger.getLogger("org.apache").setAdditivity(false);
+    //set the commons.vfs.cache logger to info, since it can contain password information
+    Logger.getLogger("org.apache.commons.vfs.cache").setLevel(Level.INFO);
     
     Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
 		public void uncaughtException(Thread t, Throwable e) {

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java?rev=687241&r1=687240&r2=687241&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java
Tue Aug 19 21:47:45 2008
@@ -303,6 +303,10 @@
               }
               selectedReceiver.shutdown();
               selectedReceiver.activateOptions();
+              //allow the visual receiver to get a container on restart
+              if (selectedReceiver instanceof VisualReceiver) {
+                  ((VisualReceiver)selectedReceiver).setContainer(ReceiversPanel.this);
+              }
             }
           };
 

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.java?rev=687241&r1=687240&r2=687241&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.java
Tue Aug 19 21:47:45 2008
@@ -222,8 +222,8 @@
    * Read and process the log file.
    */
   public void activateOptions() {
-	  
-      if (promptForUserInfo) {
+      //on receiver restart, only prompt for credentials if we don't already have them
+      if (promptForUserInfo && getFileURL().indexOf("@") == -1) {
     	  /*
     	  if promptforuserinfo is true, wait for a reference to the container 
     	  (via the VisualReceiver callback).
@@ -303,7 +303,8 @@
   private class VFSReader implements Runnable {
         public void run() {
         	FileObject fileObject = null;
-            while (reader == null) {
+        	//thread should end when we're no longer active
+            while (reader == null && isActive()) {
             	int atIndex = getFileURL().indexOf("@");
             	int protocolIndex = getFileURL().indexOf("://");
             	
@@ -315,7 +316,7 @@
                     //if jsch not in classpath, can get NoClassDefFoundError here
                     try {
                     	SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts,
"no");
-                    	SftpFileSystemConfigBuilder.getInstance().setUserInfo(opts, new MyUserInfo());
+                    	SftpFileSystemConfigBuilder.getInstance().setUserInfo(opts, new MyUserInfo(password));
                     } catch (NoClassDefFoundError ncdfe) {
                     	getLogger().warn("JSch not on classpath!", ncdfe);
                     }
@@ -353,7 +354,7 @@
                     //if jsch not in classpath, can get NoClassDefFoundError here
                     try {
                     	SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts,
"no");
-                    	SftpFileSystemConfigBuilder.getInstance().setUserInfo(opts, new MyUserInfo());
+                    	SftpFileSystemConfigBuilder.getInstance().setUserInfo(opts, new MyUserInfo(password));
                     } catch (NoClassDefFoundError ncdfe) {
                     	getLogger().warn("JSch not on classpath!", ncdfe);
                     }
@@ -388,9 +389,9 @@
                 } while (isTailing());
 
             } catch (IOException ioe) {
-                getLogger().info("stream closed");
+                getLogger().info("stream closed", ioe);
             }
-            getLogger().debug("processing " + getFileURL() + " complete");
+            getLogger().debug("processing complete");
             shutdown();
         }
     }
@@ -474,9 +475,14 @@
    * 
    * @author sdeboy
    */
-  public class MyUserInfo implements UserInfo, UIKeyboardInteractive {
+  public static class MyUserInfo implements UserInfo, UIKeyboardInteractive {
+    private final String thisPassword;
+    
+    public MyUserInfo(String thisPassword) {
+        this.thisPassword = thisPassword;
+    }
 	public String[] promptKeyboardInteractive(String destination, String loginName, String instruction,
String[] prompt, boolean[] echo) {
-		return new String[]{password};
+		return new String[]{thisPassword};
 	}
 
 	public String getPassphrase() {



Mime
View raw message