logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r1451138 - in /logging/chainsaw/trunk: pom.xml src/main/java/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.java
Date Thu, 28 Feb 2013 08:33:37 GMT
Author: sdeboy
Date: Thu Feb 28 08:33:36 2013
New Revision: 1451138

URL: http://svn.apache.org/r1451138
Log:
Committing in-progress work to support Log4j2  fileappender configurations advertised via
Multicast DNS

Modified:
    logging/chainsaw/trunk/pom.xml
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.java

Modified: logging/chainsaw/trunk/pom.xml
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/pom.xml?rev=1451138&r1=1451137&r2=1451138&view=diff
==============================================================================
--- logging/chainsaw/trunk/pom.xml (original)
+++ logging/chainsaw/trunk/pom.xml Thu Feb 28 08:33:36 2013
@@ -389,10 +389,10 @@
       <version>1.2.16</version>
     </dependency>
     <dependency>
-      <groupId>jmdns</groupId>
+      <groupId>javax.jmdns</groupId>
       <artifactId>jmdns</artifactId>
-      <version>1.0</version>
-    </dependency>    
+      <version>3.4.1</version>
+    </dependency>
     <dependency>
       <groupId>xstream</groupId>
       <artifactId>xstream</artifactId>

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.java?rev=1451138&r1=1451137&r2=1451138&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.java
Thu Feb 28 08:33:36 2013
@@ -52,11 +52,13 @@ import org.apache.log4j.BasicConfigurato
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
 import org.apache.log4j.chainsaw.ChainsawConstants;
+import org.apache.log4j.chainsaw.LogFilePatternLayoutBuilder;
 import org.apache.log4j.chainsaw.SmallButton;
 import org.apache.log4j.chainsaw.help.HelpManager;
 import org.apache.log4j.chainsaw.icons.ChainsawIcons;
 import org.apache.log4j.chainsaw.plugins.GUIPluginSkeleton;
 import org.apache.log4j.chainsaw.prefs.SettingsManager;
+import org.apache.log4j.chainsaw.vfs.VFSLogFilePatternReceiver;
 import org.apache.log4j.helpers.LogLog;
 import org.apache.log4j.net.MulticastReceiver;
 import org.apache.log4j.net.SocketHubReceiver;
@@ -116,6 +118,9 @@ public class ZeroConfPlugin extends GUIP
     private static final String XML_SOCKET_APPENDER_SERVICE_NAME = "_log4j_xml_tcpconnect_appender.local.";
     private static final String SOCKET_APPENDER_SERVICE_NAME = "_log4j_obj_tcpconnect_appender.local.";
     private static final String SOCKETHUB_APPENDER_SERVICE_NAME = "_log4j_obj_tcpaccept_appender.local.";
+    private static final String TCP_APPENDER_SERVICE_NAME = "_log4j._tcp.local.";
+    private static final String NEW_UDP_APPENDER_SERVICE_NAME = "_log4j._udp.local.";
+
     private JmDNS jmDNS;
 
     public ZeroConfPlugin() {
@@ -125,7 +130,11 @@ public class ZeroConfPlugin extends GUIP
 
     public void shutdown() {
         if (jmDNS != null) {
-            jmDNS.close();
+            try {
+                jmDNS.close();
+            } catch (Exception e) {
+                LOG.error("Unable to close JMDNS", e);
+            }
         }
         save();
     }
@@ -207,6 +216,8 @@ public class ZeroConfPlugin extends GUIP
         serviceNames.add(SOCKETHUB_APPENDER_SERVICE_NAME);
         serviceNames.add(UDP_APPENDER_SERVICE_NAME);
         serviceNames.add(XML_SOCKET_APPENDER_SERVICE_NAME);
+        serviceNames.add(TCP_APPENDER_SERVICE_NAME);
+        serviceNames.add(NEW_UDP_APPENDER_SERVICE_NAME);
 
         for (Iterator iter = serviceNames.iterator(); iter.hasNext();) {
             String serviceName = iter.next().toString();
@@ -489,6 +500,41 @@ public class ZeroConfPlugin extends GUIP
         String name = info.getName();
         String decoderClass = info.getPropertyString("decoder");
 
+        if (NEW_UDP_APPENDER_SERVICE_NAME.equals(zone))
+        {
+            UDPReceiver receiver = new UDPReceiver();
+            receiver.setPort(port);
+            receiver.setName(name + "-receiver");
+            return receiver;
+        }
+        //FileAppender or socketappender
+        //TODO: add more checks (actual layout format, etc)
+        if (TCP_APPENDER_SERVICE_NAME.equals(zone)) {
+            //CHECK content type
+            //application/octet-stream = SocketReceiver
+            //text/plain = VFSLogFilePatternReceiver (if structured=false)
+            String contentType = info.getPropertyString("contentType").toLowerCase();
+            //won't work with log4j2, as Chainsaw depends on log4j1.x
+            if ("application/octet-stream".equals(contentType))
+            {
+                SocketReceiver receiver = new SocketReceiver();
+                receiver.setPort(port);
+                receiver.setName(name + "-receiver");
+                return receiver;
+            }
+            //this will work - regular text log files are fine
+            if ("text/plain".equals(contentType))
+            {
+                VFSLogFilePatternReceiver receiver = new VFSLogFilePatternReceiver();
+                receiver.setAppendNonMatches(true);
+                receiver.setFileURL(info.getPropertyString("fileURI"));
+                receiver.setLogFormat(LogFilePatternLayoutBuilder.getLogFormatFromPatternLayout(info.getPropertyString("format")));
+                receiver.setTimestampFormat(LogFilePatternLayoutBuilder.getTimeStampFormat(info.getPropertyString("format")));
+                receiver.setName(name + "-receiver");
+                return receiver;
+            }
+        }
+
         //MulticastAppender
         if (MULTICAST_APPENDER_SERVICE_NAME.equals(zone)) {
             MulticastReceiver receiver = new MulticastReceiver();



Mime
View raw message