geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r468821 - in /geronimo/gbuild/trunk: gbuild-agent-assembly/src/main/config/gsh-log4j.properties gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/logging/SocketAppenderImpl.java
Date Sun, 29 Oct 2006 02:34:38 GMT
Author: jdillon
Date: Sat Oct 28 19:34:38 2006
New Revision: 468821

URL: http://svn.apache.org/viewvc?view=rev&rev=468821
Log:
Add custom socket appender to set hostname and hostaddr in the event MDC

Added:
    geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/logging/SocketAppenderImpl.java
  (with props)
Modified:
    geronimo/gbuild/trunk/gbuild-agent-assembly/src/main/config/gsh-log4j.properties

Modified: geronimo/gbuild/trunk/gbuild-agent-assembly/src/main/config/gsh-log4j.properties
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent-assembly/src/main/config/gsh-log4j.properties?view=diff&rev=468821&r1=468820&r2=468821
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent-assembly/src/main/config/gsh-log4j.properties (original)
+++ geronimo/gbuild/trunk/gbuild-agent-assembly/src/main/config/gsh-log4j.properties Sat Oct
28 19:34:38 2006
@@ -37,7 +37,7 @@
 log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
 log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p (%t) [%c] %m%n
 
-log4j.appender.RELAY=org.apache.log4j.net.SocketAppender
+log4j.appender.RELAY=org.apache.geronimo.gbuild.agent.logging.SocketAppenderImpl
 log4j.appender.RELAY.Threshold=INFO
 log4j.appender.RELAY.RemoteHost=gbuild.org
 log4j.appender.RELAY.Port=16162

Added: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/logging/SocketAppenderImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/logging/SocketAppenderImpl.java?view=auto&rev=468821
==============================================================================
--- geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/logging/SocketAppenderImpl.java
(added)
+++ geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/logging/SocketAppenderImpl.java
Sat Oct 28 19:34:38 2006
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gbuild.agent.logging;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.apache.log4j.net.SocketAppender;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.MDC;
+
+/**
+ * Custom socket appender which attaches <tt>hostname</tt> and <tt>hostaddr</tt>
to
+ * the {@link MDC}.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SocketAppenderImpl
+    extends SocketAppender
+{
+    public void append(final LoggingEvent event) {
+        if (event == null) {
+            return;
+        }
+
+        InetAddress localHost = null;
+        try {
+            localHost = InetAddress.getLocalHost();
+        }
+        catch (UnknownHostException e) {
+            throw new RuntimeException("Failed to lookup localhost", e);
+        }
+
+        MDC.put("hostname", localHost.getHostName());
+        MDC.put("hostaddr", localHost.getHostAddress());
+
+        super.append(event);
+    }
+}

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/logging/SocketAppenderImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/logging/SocketAppenderImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gbuild/trunk/gbuild-agent/src/main/java/org/apache/geronimo/gbuild/agent/logging/SocketAppenderImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message