logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grobme...@apache.org
Subject svn commit: r1345492 [11/18] - in /logging/log4j/branches/log4j12modules: ./ contribs/ contribs/CekiGulcu/ contribs/EirikLygre/ contribs/JamesHouse/ contribs/Jamie Tsao/ contribs/JimMoore/ contribs/KevinSteppe/ contribs/KitchingSimon/ contribs/LeosLite...
Date Sat, 02 Jun 2012 11:41:11 GMT
Added: logging/log4j/branches/log4j12modules/modules/contribs/src/main/java/org/apache/log4j/net/RootRequestHandler.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/main/java/org/apache/log4j/net/RootRequestHandler.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/contribs/src/main/java/org/apache/log4j/net/RootRequestHandler.java (added)
+++ logging/log4j/branches/log4j12modules/modules/contribs/src/main/java/org/apache/log4j/net/RootRequestHandler.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,159 @@
+/*
+ * 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.log4j.net;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+/**
+ * This class implements a RequestHandler for the root path "/" in the PluggableHTTPServer.
+ * A simple HTML message will be replied to the client.
+ *
+ * @author <a HREF="mailto:V.Mentzner@psi-bt.de">Volker Mentzner</a>
+ */
+public class RootRequestHandler implements HTTPRequestHandler {
+
+  private String title;
+  private String description;
+  private String handledPath;
+  private String ReplyType = "Content-type: text/html\r\n\r\n";
+  private String ReplyHTML = "<HTML><HEAD><TITLE>Root</TITLE></HEAD>\r\n"
+                           + "<BODY><H1>Root</H1>\r\n"
+                           + "</BODY></HTML>\r\n";
+
+ /**
+   * Creates a new RootRequestHandler object
+   */
+  public RootRequestHandler() {
+    this.setTitle("root page");
+    this.setDescription("root page");
+    this.setHandledPath("/");
+  }
+
+  /**
+   * Gets the content type of the reply HTTP message
+   *
+   * @return content type as String
+   */
+  public String getReplyType() {
+    return this.ReplyType;
+  }
+
+  /**
+   * Sets the content type of the reply HTTP message
+   *
+   * @param ReplyType - content type as String
+   */
+  public void setReplyType(String ReplyType) {
+    this.ReplyType = ReplyType;
+  }
+
+  /**
+   * Gets the HTML data of the reply HTTP message
+   *
+   * @return HTML message as String
+   */
+  public String getReplyHTML() {
+    return this.ReplyHTML;
+  }
+
+  /**
+   * Sets the HTML data of the reply HTTP message
+   *
+   * @param ReplyHTML - HTML message as String
+   */
+  public void setReplyHTML(String ReplyHTML) {
+    this.ReplyHTML = ReplyHTML;
+  }
+
+ /**
+   * Gets the title for html page
+   */
+  public String getTitle() {
+    return this.title;
+  }
+
+ /**
+   * Sets the title for html page
+   */
+  public void setTitle(String title) {
+    this.title = title;
+  }
+
+ /**
+   * Gets the description for html page
+   */
+  public String getDescription() {
+    return this.description;
+  }
+
+ /**
+   * Sets the description for html page
+   */
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  /**
+   * Gets the server path
+   *
+   * @return the server path
+   */
+  public String getHandledPath() {
+    return this.handledPath;
+  }
+
+  /**
+   * Sets the server path
+   *
+   * @param path - the server path
+   */
+  public void setHandledPath(String path) {
+    this.handledPath = path;
+  }
+
+ /**
+   * Handles the given request and writes the reply to the given out-stream.
+   *
+   * @param request - client browser request
+   * @param out - Out stream for sending data to client browser
+   * @return if the request was handled by this handler : true, else : false
+   */
+  public boolean handleRequest(String request, Writer out) {
+    String path = "";
+    String query = null;
+    try {
+      URL url = new URL("http://localhost"+request);
+      path = url.getPath();
+      query = url.getPath();
+      if (path.equals(handledPath) == false) {
+        return false;
+      }
+
+      out.write("HTTP/1.0 200 OK\r\n");
+      if (ReplyType != null)
+        out.write(ReplyType);
+      if (ReplyHTML != null)
+        out.write(ReplyHTML);
+      out.flush();
+      return true;
+    } catch (Exception ex) {
+      return false;
+    }
+  }
+}
\ No newline at end of file

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/main/java/org/apache/log4j/net/RootRequestHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderLog4JTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderLog4JTest.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderLog4JTest.java (added)
+++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderLog4JTest.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,53 @@
+package org.apache.log4j.contribs.ThomasFenner;
+/*
+ * 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.
+ */
+
+// Here is a code example to configure the JDBCAppender with a configuration-file
+
+import org.apache.log4j.*;
+
+import java.sql.*;
+
+public class JDBCAppenderLog4JTest
+{
+   // Create a category instance for this class
+   static Category cat = Category.getInstance(JDBCAppenderLog4JTest.class.getName());
+
+   public static void main(String[] args)
+   {
+      // Ensure to have all necessary drivers installed !
+      try
+      {
+         Driver d = (Driver)(Class.forName("oracle.jdbc.driver.OracleDriver").newInstance());
+         DriverManager.registerDriver(d);
+      }
+      catch(Exception e){}
+
+      // Set the priority which messages have to be logged
+      cat.setPriority(Priority.INFO);
+
+      // Configuration with configuration-file
+      PropertyConfigurator.configure("log4jtestprops.txt");
+
+      // These messages with Priority >= setted priority will be logged to the database.
+      cat.debug("debug");  //this not, because Priority DEBUG is less than INFO
+      cat.info("info");
+      cat.error("error");
+      cat.fatal("fatal");
+   }
+}
+

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderLog4JTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderNoConfigFileLog4JTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderNoConfigFileLog4JTest.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderNoConfigFileLog4JTest.java (added)
+++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderNoConfigFileLog4JTest.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,134 @@
+package org.apache.log4j.contribs.ThomasFenner;
+/*
+ * 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.
+ */
+
+// Here is a code example to configure the JDBCAppender without a configuration-file
+
+import org.apache.log4j.*;
+import org.apache.log4j.net.JDBCAppender;
+import org.apache.log4j.net.JDBCConnectionHandler;
+import org.apache.log4j.net.JDBCIDHandler;
+import org.apache.log4j.net.LogType;
+
+import java.sql.*;
+import java.util.*;
+
+public class JDBCAppenderNoConfigFileLog4JTest
+{
+	// Create a category instance for this class
+	static Category cat = Category.getInstance(JDBCAppenderNoConfigFileLog4JTest.class.getName());
+
+	public static void main(String[] args)
+	{
+		// A JDBCIDHandler
+		MyIDHandler idhandler = new MyIDHandler();
+
+		// Ensure to have all necessary drivers installed !
+		try
+		{
+			Driver d = (Driver)(Class.forName("oracle.jdbc.driver.OracleDriver").newInstance());
+			DriverManager.registerDriver(d);
+		}
+		catch(Exception e){}
+
+		// Set the priority which messages have to be logged
+		cat.setPriority(Priority.DEBUG);
+
+		// Create a new instance of JDBCAppender
+		JDBCAppender ja = new JDBCAppender();
+
+		// Set options with method setOption()
+		ja.setOption(JDBCAppender.CONNECTOR_OPTION, "MyConnectionHandler");
+		ja.setOption(JDBCAppender.URL_OPTION, "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1521))(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1526)))(CONNECT_DATA=(SID=LENZI)))");
+		ja.setOption(JDBCAppender.USERNAME_OPTION, "mex_pr_dev60");
+		ja.setOption(JDBCAppender.PASSWORD_OPTION, "mex_pr_dev60");
+
+		ja.setOption(JDBCAppender.TABLE_OPTION, "logtest");
+
+		// There are two ways to setup the column-descriptions :
+		// 1. Use the the method setOption(JDBCAppender.COLUMNS_OPTION, column-description)
+		//ja.setOption(JDBCAppender.COLUMNS_OPTION, "id_seq~EMPTY	id~ID~MyIDHandler	msg~MSG	created_on~TIMESTAMP	created_by~STATIC~:-) Thomas Fenner (t.fenner@klopotek.de)");
+
+		// 2. Use the better way of coding with method setLogType(String columnname, int LogType.xxx, Object xxx)
+		ja.setLogType("id_seq", LogType.EMPTY, "");
+		ja.setLogType("id", LogType.ID, idhandler);
+		ja.setLogType("msg", LogType.MSG, "");
+		ja.setLogType("created_on", LogType.TIMESTAMP, "");
+		ja.setLogType("created_by", LogType.STATIC, "FEN");
+
+		// If you just want to perform a static sql-statement, forget about the table- and columns-options,
+		// and use this one :
+		//ja.setOption(JDBCAppender.SQL_OPTION, "INSERT INTO LOGTEST (id, msg, created_on, created_by) VALUES (1, @MSG@, sysdate, 'me')");
+
+		// other options
+		//ja.setOption(JDBCAppender.BUFFER_OPTION, "1");
+		//ja.setOption(JDBCAppender.COMMIT_OPTION, "Y");
+
+		// Define a layout
+		//ja.setLayout(new PatternLayout("%m"));
+
+		// Add the appender to a category
+		cat.addAppender(ja);
+
+		// These messages with Priority >= setted priority will be logged to the database.
+		cat.debug("debug");
+		cat.info("info");
+		cat.error("error");
+		cat.fatal("fatal");
+	}
+}
+
+// Implement a sample JDBCConnectionHandler
+class MyConnectionHandler implements JDBCConnectionHandler
+{
+	Connection con = null;
+   //Default connection
+	String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1521))(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1526)))(CONNECT_DATA=(SID=LENZI)))";
+   String username = "mex_pr_dev60";
+   String password = "mex_pr_dev60";
+
+   public Connection getConnection()
+   {
+	return getConnection(url, username, password);
+   }
+
+   public Connection getConnection(String _url, String _username, String _password)
+   {
+	try
+	  {
+		if(con != null && !con.isClosed()) con.close();
+			con = DriverManager.getConnection(_url, _username, _password);
+			con.setAutoCommit(false);
+	  }
+	  catch(Exception e){}
+
+	return con;
+   }
+}
+
+
+// Implement a sample JDBCIDHandler
+class MyIDHandler implements JDBCIDHandler
+{
+	private static long id = 0;
+
+	public synchronized Object getID()
+   {
+		return new Long(++id);
+   }
+}
+

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderNoConfigFileLog4JTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderWithConfigFileLog4JTest.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderWithConfigFileLog4JTest.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderWithConfigFileLog4JTest.java (added)
+++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderWithConfigFileLog4JTest.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,274 @@
+package org.apache.log4j.contribs.ThomasFenner;
+/*
+ * 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.
+ */
+/**
+// Class JDBCAppender, writes messages into a database
+
+// The JDBCAppender is configurable at runtime in two alternatives :
+// 1. Configuration-file
+//    Define the options in a file and call a PropertyConfigurator.configure(file)-method.
+// 2. method JDBCAppender::setOption(JDBCAppender.xxx_OPTION, String value)
+
+// The sequence of some options is important :
+// 1. Connector-option OR/AND Database-options
+//    Any database connection is required !
+// 2. (Table-option AND Columns-option) OR SQL-option
+//		Any statement is required !
+// 3. All other options can be set at any time...
+//    The other options are optional and have a default initialization, which can be custumized.
+
+// All available options are defined as static String-constants in JDBCAppender named xxx_OPTION.
+
+// Here is a description of all available options :
+// 1. Database-options to connect to the database
+//    - URL_OPTION			: a database url of the form jdbc:subprotocol:subname
+//    - USERNAME_OPTION		: the database user on whose behalf the connection is being made
+//    - PASSWORD_OPTION		: the user's password
+//
+// 2. Connector-option to specify your own JDBCConnectionHandler
+//    - CONNECTOR_OPTION	: a classname which is implementing the JDBCConnectionHandler-interface
+//    This interface is used to get a customized connection.
+//    If in addition the database-options are given, these options will be used
+//    for invocation of the JDBCConnectionHandler-interface to get a connection.
+//    Else if no database-options are given, the JDBCConnectionHandler-interface is called without these options.
+//
+// 3. SQL-option to specify a static sql-statement which will be performed with every occuring message-event
+//    - SQL_OPTION			: a sql-statement which will be used to write to the database
+//    If you give this option, the table-option and columns-option will be ignored !
+//    Use the variable @MSG@ on that location in the statement, which has to be dynamically replaced by the message.
+//
+// 4. Table-option to specify one table contained by the database
+//    - TABLE_OPTION			: the table in which the logging will be done
+//
+// 5. Columns-option to describe the important columns of the table (Not nullable columns are mandatory to describe!)
+//    - COLUMNS_OPTION		: a formatted list of column-descriptions
+//    Each column description consists of
+//       - the name of the column (required)
+//			- a logtype which is a static constant of class LogType (required)
+//       - and a value which depends by the LogType (optional/required, depending by logtype)
+//    Here is a description of the available logtypes of class LogType :
+//       o MSG			= a value will be ignored, the column will get the message. (One columns need to be of this type!)
+//       o STATIC		= the value will be filled into the column with every logged message. (Ensure that the type of value can be casted into the sql-type of the column!)
+//       o ID			= value must be a classname, which implements the JDBCIDHandler-interface.
+//       o TIMESTAMP	= a value will be ignored, the column will be filled with a actually timestamp with every logged message.
+//       o EMPTY		= a value will be ignored, the column will be ignored when writing to the database (Ensure to fill not nullable columns by a database trigger!)
+//    If there are more than one column to describe, the columns must be separated by a TAB-delimiter ('	') !
+//    The arguments of a column-description must be separated by the delimiter '~' !
+//		(Example :  name1~logtype1~value1	name2~logtype2~value2...)
+//
+// 6. Layout-options to define the layout of the messages (optional)
+//    - the layout wont be set by a xxx_OPTION
+//    Configuration-file			: see at the following configuration-file example
+//    JDBCAppender::setOption()	: see at the following code example
+//    The default is a layout of class org.apache.log4j.PatternLayout with ConversionPattern=%m
+//
+// 7. Buffer-option to define the size of the message-event-buffer (optional)
+//    - BUFFER_OPTION		: define how many messages will be buffered until they will be updated to the database.
+//    The default is a update on every message (buffer=1=no buffer).
+//
+// 8. Commit-option to define a auto-commitment
+//    - COMMIT_OPTION		: define whether updated messages should be committed to the database (Y) or not (N).
+//    The default is a commit on every buffer-flush.
+
+
+// Here is a Configuration-file example, which can be used with the PropertyConfigurator :
+//
+// Declare a appender variable named JDBC
+log4j.rootCategory=JDBC
+
+// JDBC is a class of JDBCAppender, which writes messages into a database
+log4j.appender.JDBC=JDBCAppender
+
+// 1. Database-options to connect to the database
+log4j.appender.JDBC.url=jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1521))(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1526)))(CONNECT_DATA=(SID=LENZI)))
+log4j.appender.JDBC.username=mex_pr_dev60
+log4j.appender.JDBC.password=mex_pr_dev60
+
+// 2. Connector-option to specify your own JDBCConnectionHandler
+log4j.appender.JDBC.connector=MyConnectionHandler
+
+// 3. SQL-option to specify a static sql-statement which will be performed with every occuring message-event
+log4j.appender.JDBC.sql=INSERT INTO LOGTEST (id, msg, created_on, created_by) VALUES (1, @MSG@, sysdate, 'me')
+
+// 4. Table-option to specify one table contained by the database
+log4j.appender.JDBC.table=logtest
+
+// 5. Columns-option to describe the important columns of the table (Not nullable columns are mandatory to describe!)
+log4j.appender.JDBC.columns=id_seq~EMPTY	id~ID~MyIDHandler	msg~MSG	created_on~TIMESTAMP	created_by~STATIC~Thomas Fenner (t.fenner@klopotek.de)
+
+// 6. Layout-options to define the layout of the messages (optional)
+log4j.appender.JDBC.layout=org.apache.log4j.PatternLayout
+log4j.appender.JDBC.layout.ConversionPattern=%m
+
+// 7. Buffer-option to define the size of the message-event-buffer (optional)
+log4j.appender.JDBC.buffer=1
+
+// 8. Commit-option to define a auto-commitment
+log4j.appender.JDBC.commit=Y
+*/
+
+// Here is a code example to configure the JDBCAppender with a configuration-file :
+
+import org.apache.log4j.*;
+import org.apache.log4j.net.JDBCConnectionHandler;
+import org.apache.log4j.net.JDBCIDHandler;
+
+import java.sql.*;
+import java.util.*;
+
+public class JDBCAppenderWithConfigFileLog4JTest
+{
+	// Create a category instance for this class
+   static Category cat = Category.getInstance(JDBCAppenderWithConfigFileLog4JTest.class.getName());
+
+   public static void main(String[] args)
+   {
+      // Ensure to have all necessary drivers installed !
+   	try
+      {
+			Driver d = (Driver)(Class.forName("oracle.jdbc.driver.OracleDriver").newInstance());
+			DriverManager.registerDriver(d);
+		}
+      catch(Exception e){}
+
+      // Set the priority which messages have to be logged
+		cat.setPriority(Priority.INFO);
+
+		// Configuration with configuration-file
+		PropertyConfigurator.configure("log4jtestprops.txt");
+
+      // These messages with Priority >= setted priority will be logged to the database.
+  		cat.debug("debug");  //this not, because Priority DEBUG is less than INFO
+      cat.info("info");
+      cat.error("error");
+      cat.fatal("fatal");
+   }
+}
+
+// Here is a code example to configure the JDBCAppender without a configuration-file :
+/*
+import org.apache.log4j.*;
+import java.sql.*;
+import java.lang.*;
+import java.util.*;
+
+public class Log4JTest
+{
+	// Create a category instance for this class
+   static Category cat = Category.getInstance(Log4JTest.class.getName());
+
+   public static void main(String[] args)
+   {
+   	// A JDBCIDHandler
+	   MyIDHandler idhandler = new MyIDHandler();
+
+      // Ensure to have all necessary drivers installed !
+   	try
+      {
+			Driver d = (Driver)(Class.forName("oracle.jdbc.driver.OracleDriver").newInstance());
+			DriverManager.registerDriver(d);
+		}
+      catch(Exception e){}
+
+      // Set the priority which messages have to be logged
+		cat.setPriority(Priority.DEBUG);
+
+      // Create a new instance of JDBCAppender
+      JDBCAppender ja = new JDBCAppender();
+
+      // Set options with method setOption()
+      ja.setOption(JDBCAppender.CONNECTOR_OPTION, "MyConnectionHandler");
+      ja.setOption(JDBCAppender.URL_OPTION, "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1521))(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1526)))(CONNECT_DATA=(SID=LENZI)))");
+      ja.setOption(JDBCAppender.USERNAME_OPTION, "mex_pr_dev60");
+      ja.setOption(JDBCAppender.PASSWORD_OPTION, "mex_pr_dev60");
+
+		ja.setOption(JDBCAppender.TABLE_OPTION, "logtest");
+
+      // There are two ways to setup the column-descriptions :
+      // 1. Use the the method setOption(JDBCAppender.COLUMNS_OPTION, column-description)
+		//ja.setOption(JDBCAppender.COLUMNS_OPTION, "id_seq~EMPTY	id~ID~MyIDHandler	msg~MSG	created_on~TIMESTAMP	created_by~STATIC~:-) Thomas Fenner (t.fenner@klopotek.de)");
+		// 2. Use the better way of coding with method setLogType(String columnname, int LogType.xxx, Object xxx)
+		ja.setLogType("id_seq", LogType.EMPTY, "");
+		ja.setLogType("id", LogType.ID, idhandler);
+		ja.setLogType("msg", LogType.MSG, "");
+		ja.setLogType("created_on", LogType.TIMESTAMP, "");
+		ja.setLogType("created_by", LogType.STATIC, "FEN");
+
+      // If you just want to perform a static sql-statement, forget about the table- and columns-options,
+      // and use this one :
+		//ja.setOption(JDBCAppender.SQL_OPTION, "INSERT INTO LOGTEST (id, msg, created_on, created_by) VALUES (1, @MSG@, sysdate, 'me')");
+
+      // other options
+		//ja.setOption(JDBCAppender.BUFFER_OPTION, "1");
+		//ja.setOption(JDBCAppender.COMMIT_OPTION, "Y");
+
+      // Define a layout
+		//ja.setLayout(new PatternLayout("%m"));
+
+      // Add the appender to a category
+      cat.addAppender(ja);
+
+      // These messages with Priority >= setted priority will be logged to the database.
+		cat.debug("debug");
+      cat.info("info");
+      cat.error("error");
+      cat.fatal("fatal");
+	}
+}
+*/
+
+// Implement a sample JDBCConnectionHandler
+class JDBCAppenderWithConfigFileLog4JTestConnectionHandler implements JDBCConnectionHandler
+{
+	Connection con = null;
+   //Default connection
+	String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1521))(ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=LENZI)(Port=1526)))(CONNECT_DATA=(SID=LENZI)))";
+   String username = "mex_pr_dev60";
+   String password = "mex_pr_dev60";
+
+   public Connection getConnection()
+   {
+   	return getConnection(url, username, password);
+   }
+
+   public Connection getConnection(String _url, String _username, String _password)
+   {
+   	try
+      {
+   		if(con != null && !con.isClosed()) con.close();
+			con = DriverManager.getConnection(_url, _username, _password);
+			con.setAutoCommit(false);
+      }
+      catch(Exception e){}
+
+   	return con;
+   }
+}
+
+
+// Implement a sample JDBCIDHandler
+class JDBCAppenderWithConfigFileIDHandler implements JDBCIDHandler
+{
+	private static long id = 0;
+
+	public synchronized Object getID()
+   {
+		return new Long(++id);
+   }
+}
+
+

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/JDBCAppenderWithConfigFileLog4JTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/configfile_example.txt (from r1345481, logging/log4j/branches/log4j12modules/contribs/ThomasFenner/configfile_example.txt)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/configfile_example.txt?p2=logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/configfile_example.txt&p1=logging/log4j/branches/log4j12modules/contribs/ThomasFenner/configfile_example.txt&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/configfile_example.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/java/org/apache/log4j/contribs/ThomasFenner/configfile_example.txt
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/CompositeRollingAppender.java (from r1345481, logging/log4j/branches/log4j12modules/contribs/KevinSteppe/CompositeRollingAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/CompositeRollingAppender.java?p2=logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/CompositeRollingAppender.java&p1=logging/log4j/branches/log4j12modules/contribs/KevinSteppe/CompositeRollingAppender.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/CompositeRollingAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/CompositeRollingAppender.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/DailyFileAppender.java (from r1345481, logging/log4j/branches/log4j12modules/contribs/EirikLygre/DailyFileAppender1.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/DailyFileAppender.java?p2=logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/DailyFileAppender.java&p1=logging/log4j/branches/log4j12modules/contribs/EirikLygre/DailyFileAppender1.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/DailyFileAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/DailyFileAppender.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/TempFileAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/TempFileAppender.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/TempFileAppender.java (added)
+++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/TempFileAppender.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,198 @@
+/*
+ * 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.log4j;
+ 
+import java.io.File;
+import java.io.Writer;
+import java.io.FileWriter;
+import java.io.BufferedWriter;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.helpers.OptionConverter;
+import org.apache.log4j.spi.ErrorHandler;
+
+/**
+   TempFileAppender creates new unique file for each logging statement.
+ 
+   @author <a HREF="mailto:leos.literak@12snap.com">Leos Literak</a>
+   @author Ceki G&uuml;lc&uuml;
+ 
+*/
+public class TempFileAppender extends AppenderSkeleton {
+ 
+  /**
+     A string constant used in naming the option for setting the
+     directory where the log files will be created. Current value 
+     of this string constant is <b>Path</b>. java.io.tmpdir directory
+     will be used, if ommited.
+   */
+  static final public String PATH_OPTION = "Path";
+  
+  /**
+     The default path is actual directory.
+  */
+  protected String path = null;
+ 
+  /**
+     A string constant used in naming the option for setting the
+     prefix of the log files. It has to have at least 3 characters!
+     Current value of this string constant is <b>Prefix</b>.
+   */
+  static final public String PREFIX_OPTION = "Prefix";
+  
+  /**
+     The default path is actual directory.
+  */
+  protected String prefix = "l4j_";
+ 
+  /**
+     A string constant used in naming the option for setting the
+     suffix of the log files. Current value of this string constant 
+     is <b>Suffix</b>.
+   */
+  static final public String SUFFIX_OPTION = "Suffix";
+  
+  /**
+     The default path is actual directory.
+  */
+  protected String suffix = ".tmp";
+  
+  /**
+     Default dir
+  */
+  
+  protected File dir = null;
+
+
+
+
+  /**
+     The default constructor simply calls its parent's constructor. 
+  */
+  public TempFileAppender() {
+      super();
+  }
+ 
+  /**
+     Retuns the option names for this component
+  */
+  public String[] getOptionStrings() {
+      return OptionConverter.concatanateArrays(super.getOptionStrings(),
+                 new String[] {PATH_OPTION,PREFIX_OPTION,SUFFIX_OPTION});
+  }  
+
+  /**
+     Set TempFileAppender specific options.
+ 
+     The recognized options are <b>Path</b>, <b>Prefix</b> and <b>Suffix</b>,
+     i.e. the values of the string constants {@link #PATH_OPTION}, 
+     {@link #PREFIX_OPTION} and respectively {@link #SUFFIX_OPTION}. 
+     The options of the super class {@link AppenderSkeleton} are also 
+     recognized.
+  */
+  
+  public void setOption(String key, String value) {
+      super.setOption(key, value);
+      if(key.equalsIgnoreCase(PATH_OPTION)) {
+	  path = value;
+	  if(path==null) {
+              errorHandler.error("Path cannot be empty!",null,0);
+	  }
+
+	  dir = new File(path);
+	  if(!(dir.exists() && dir.isDirectory() && dir.canWrite())) {
+              errorHandler.error("Cannot write to directory " + path + "!",null,0);
+	  }
+      }
+      else if(key.equalsIgnoreCase(PREFIX_OPTION)) {
+          if(value!=null && value.length()>=3) {
+	      prefix = value;
+	  } else {
+              errorHandler.error("Prefix cannot be shorter than 3 characters!",
+	                         null,0);
+	  }
+      }
+      else if(key.equalsIgnoreCase(SUFFIX_OPTION)) {
+          if(value!=null && value.length()>=1) {
+	      suffix = value;
+	  } else {
+              errorHandler.error("Suffix cannot be empty!",null,0);
+	  }
+      }
+  }
+
+  /**
+     This method is called by {@link AppenderSkeleton#doAppend}
+     method.
+ 
+     <p>Whenever this method is called, new unique file is created
+     with specified prefix and suffix. The file is closed afterwards.
+ 
+     <p>The format of the output will depend on this appender's
+     layout.
+ 
+  */ 
+  public void append(LoggingEvent event) { 
+      if(!checkEntryConditions()) {
+          return;
+      }
+      subAppend(event);
+  }
+ 
+  /**
+     This method determines if there is a sense in attempting to append.
+  */
+  protected boolean checkEntryConditions() {
+      return true;
+  }   
+
+  /**
+     This method does actual writing
+  */
+  protected void subAppend(LoggingEvent event) {
+      try {
+          File tmp = File.createTempFile(prefix,suffix,dir);
+	  Writer out = new BufferedWriter(new FileWriter(tmp));
+	  out.write(event.message);
+	  out.close();
+ /* this Appender is not supposed to be used for logging of Exceptions */
+      } catch (Exception e) {
+          errorHandler.error("Error during creation of temporary File!",e,1);
+      }
+  }
+  
+  public boolean requiresLayout() {
+      return false;
+  }
+  
+  public void close() {
+  /* nothing to do */
+  }
+} 
+/*
+ * @author $Author$
+ * @version $Revision$
+ * @since $Date$
+ *
+ * $Log$
+ * Revision 1.1.2.1  2005/05/27 03:27:54  mwomack
+ * Fix for #35032.  Added license header to .java files that did not already have a license.
+ *
+ * Revision 1.1  2001/04/20 17:38:31  ceki
+ *
+ * Added LeosLiterak's TempFileAppender.java
+ *
+*/

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/TempFileAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/LogTextPanel.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/LogTextPanel.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/LogTextPanel.java (added)
+++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/LogTextPanel.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,191 @@
+/*
+ * 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.log4j.gui;
+
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.awt.BorderLayout;
+
+import javax.swing.*;
+import javax.swing.text.StyledDocument;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.StyleConstants;
+
+import java.util.Hashtable;
+import java.util.StringTokenizer;
+import java.util.Enumeration;
+import java.util.ArrayList;
+
+import org.apache.log4j.*;
+
+/**
+ * @author James House
+ */
+public class LogTextPanel extends JPanel {
+
+  private JScrollBar scrollBar;
+  private JTextPane textPane;
+  private JCheckBox cbxTail;
+  private StyledDocument doc;
+
+  private Hashtable fontAttributes;
+
+  private int eventBufferMaxSize = 10000;
+  private ArrayList eventBuffer = new ArrayList(eventBufferMaxSize);
+  private int eventViewIndex = 0;
+
+  public LogTextPanel() {
+    constructComponents();
+    createDefaultFontAttributes();
+  }
+
+  private void constructComponents() {
+      // setup the panel's additional components...
+    this.setLayout(new BorderLayout());
+
+    cbxTail = new JCheckBox();
+    cbxTail.setSelected(true);
+    cbxTail.setText("Tail log events");
+
+    JPanel bottomPanel = new JPanel();
+    bottomPanel.add(cbxTail, null);
+
+    textPane = new JTextPane();
+    textPane.setEditable(false);
+    textPane.setText("");
+    doc = textPane.getStyledDocument();
+
+    scrollBar = new JScrollBar(JScrollBar.VERTICAL);
+
+    this.add(bottomPanel, BorderLayout.SOUTH);
+    this.add(scrollBar, BorderLayout.EAST);
+    this.add(textPane, BorderLayout.CENTER);
+  }
+
+  public
+  void setTextBackground(Color color) {
+    textPane.setBackground(color);
+  }
+
+  public
+  void setTextBackground(String v) {
+    textPane.setBackground(parseColor(v));
+  }
+
+  private void createDefaultFontAttributes() {
+    Priority[] prio = Priority.getAllPossiblePriorities();
+
+    fontAttributes = new Hashtable();
+    for (int i=0; i<prio.length;i++) {
+      MutableAttributeSet att = new SimpleAttributeSet();
+      fontAttributes.put(prio[i], att);
+      //StyleConstants.setFontSize(att,11);
+    }
+
+    setTextColor(Priority.FATAL, Color.red);
+    setTextColor(Priority.ERROR, Color.magenta);
+    setTextColor(Priority.WARN, Color.orange);
+    setTextColor(Priority.INFO, Color.blue);
+    setTextColor(Priority.DEBUG, Color.black);
+  }
+
+  private
+  Color parseColor (String v) {
+    StringTokenizer st = new StringTokenizer(v,",");
+    int val[] = {255,255,255,255};
+    int i=0;
+    while (st.hasMoreTokens()) {
+      val[i]=Integer.parseInt(st.nextToken());
+      i++;
+    }
+    return new Color(val[0],val[1],val[2],val[3]);
+  }
+
+  void setTextColor(Priority p, String v) {
+    StyleConstants.setForeground(
+          (MutableAttributeSet)fontAttributes.get(p),parseColor(v));
+  }
+
+  void setTextColor(Priority p, Color c) {
+    StyleConstants.setForeground(
+          (MutableAttributeSet)fontAttributes.get(p),c);
+  }
+
+  void setTextFontSize(int size) {
+    Enumeration e = fontAttributes.elements();
+    while (e.hasMoreElements()) {
+      StyleConstants.setFontSize((MutableAttributeSet)e.nextElement(),size);
+    }
+    return;
+  }
+
+  void setTextFontName(String name) {
+    Enumeration e = fontAttributes.elements();
+    while (e.hasMoreElements()) {
+      StyleConstants.setFontFamily((MutableAttributeSet)e.nextElement(),name);
+    }
+    return;
+  }
+
+  void setEventBufferSize(int bufferSize) {
+    eventBufferMaxSize = bufferSize;
+  }
+
+  void newEvents(EventBufferElement[] evts) {
+
+    if((eventBuffer.size() + evts.length) >= eventBufferMaxSize) {
+      for(int i=0; i < evts.length; i++) {
+        eventBuffer.remove(0);
+      }
+      eventViewIndex -= evts.length;
+      if(eventViewIndex < 0)
+        eventViewIndex = 0;
+    }
+    for(int i=0; i < evts.length; i++)
+      eventBuffer.add(evts[i]);
+
+    if((eventBuffer.size() > maxR) && cbxTail.isSelected()) {
+      eventViewIndex = (eventBuffer.size() - maxR);
+    }
+
+    // only redraw if new line is visible...
+    if((maxR < 0) || (eventBuffer.size() >= eventViewIndex && eventBuffer.size() <= (eventViewIndex + maxR)))
+      drawText();
+  }
+
+  int maxR = -1;
+
+  void drawText() {
+    if(maxR < 0)
+      maxR =  textPane.getHeight() / textPane.getFontMetrics(textPane.getFont()).getHeight();
+    try {
+      doc.remove(0, doc.getLength());
+    } catch(Exception e) { e.printStackTrace(); }
+
+    for(int i=eventViewIndex; (i < eventBuffer.size()) && (i < (eventViewIndex + maxR)); i++) {
+      EventBufferElement evt = (EventBufferElement)eventBuffer.get(i);
+
+      try {
+        doc.insertString(doc.getLength(), evt.text, (MutableAttributeSet)fontAttributes.get(evt.prio));
+      } catch(Exception e) { e.printStackTrace(); }
+    }
+  }
+
+
+}
\ No newline at end of file

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/LogTextPanel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/TextPaneAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/TextPaneAppender.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/TextPaneAppender.java (added)
+++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/TextPaneAppender.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,354 @@
+/*
+ * 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.log4j.gui;
+
+
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.io.*;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.Hashtable;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.JTextPane;
+import javax.swing.text.AttributeSet;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyledDocument;
+import javax.swing.text.TabSet;
+import javax.swing.text.TabStop;
+
+import org.apache.log4j.*;
+
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.helpers.Loader;
+import org.apache.log4j.helpers.QuietWriter;
+import org.apache.log4j.helpers.TracerPrintWriter;
+import org.apache.log4j.helpers.OptionConverter;
+
+
+/**
+ * <b>Experimental</b> TextPaneAppender. <br>
+ *
+ *
+ * Created: Sat Feb 26 18:50:27 2000 <br>
+ *
+ * @author Sven Reimers
+ */
+public class TextPaneAppender extends AppenderSkeleton {
+    
+  JTextPane textpane;
+  StyledDocument doc;
+  TracerPrintWriter tp;
+  StringWriter sw;
+  QuietWriter qw;
+  Hashtable attributes;
+  Hashtable icons;
+  
+  private String label;
+  
+  private boolean fancy;
+    
+  final String LABEL_OPTION = "Label";
+  final String COLOR_OPTION_FATAL = "Color.Emerg";
+  final String COLOR_OPTION_ERROR = "Color.Error";
+  final String COLOR_OPTION_WARN = "Color.Warn";
+  final String COLOR_OPTION_INFO = "Color.Info";
+  final String COLOR_OPTION_DEBUG = "Color.Debug";
+  final String COLOR_OPTION_BACKGROUND = "Color.Background";
+  final String FANCY_OPTION = "Fancy";
+  final String FONT_NAME_OPTION = "Font.Name";
+  final String FONT_SIZE_OPTION = "Font.Size";
+  
+  public static Image loadIcon ( String path ) {
+    Image img = null;
+    try {
+      URL url = ClassLoader.getSystemResource(path);
+      img = (Image) (Toolkit.getDefaultToolkit()).getImage(url);
+    } catch (Exception e) {
+      System.out.println("Exception occured: " + e.getMessage() + 
+			 " - " + e );   
+    }	
+    return (img);
+  }
+  
+  public TextPaneAppender(Layout layout, String name) {
+    this();
+    this.layout = layout;
+    this.name = name;
+    setTextPane(new JTextPane());
+    createAttributes();
+    createIcons();
+  }
+    
+  public TextPaneAppender() {
+    super();
+    setTextPane(new JTextPane());
+    createAttributes();
+    createIcons();
+    this.label="";
+    this.sw = new StringWriter();
+    this.qw = new QuietWriter(sw, errorHandler);
+    this.tp = new TracerPrintWriter(qw);
+    this.fancy =true;
+  }
+
+  public
+  void close() {
+    
+  }
+  
+  private void createAttributes() {	
+    Priority prio[] = Priority.getAllPossiblePriorities();
+    
+    attributes = new Hashtable();
+    for (int i=0; i<prio.length;i++) {
+      MutableAttributeSet att = new SimpleAttributeSet();
+      attributes.put(prio[i], att);
+      StyleConstants.setFontSize(att,14);
+    }
+    StyleConstants.setForeground((MutableAttributeSet)attributes.get(Priority.ERROR),Color.red);
+    StyleConstants.setForeground((MutableAttributeSet)attributes.get(Priority.WARN),Color.orange);
+    StyleConstants.setForeground((MutableAttributeSet)attributes.get(Priority.INFO),Color.gray);
+    StyleConstants.setForeground((MutableAttributeSet)attributes.get(Priority.DEBUG),Color.black);
+  }
+
+  private void createIcons() {
+    Priority prio[] = Priority.getAllPossiblePriorities();
+    
+    icons = new Hashtable();
+    for (int i=0; i<prio.length;i++) {
+      if (prio[i].equals(Priority.FATAL))
+	icons.put(prio[i],new ImageIcon(loadIcon("icons/RedFlag.gif")));
+      if (prio[i].equals(Priority.ERROR))		
+	icons.put(prio[i],new ImageIcon(loadIcon("icons/RedFlag.gif")));
+      if (prio[i].equals(Priority.WARN))		
+	icons.put(prio[i],new ImageIcon(loadIcon("icons/BlueFlag.gif")));
+      if (prio[i].equals(Priority.INFO))		
+	icons.put(prio[i],new ImageIcon(loadIcon("icons/GreenFlag.gif")));
+      if (prio[i].equals(Priority.DEBUG))		
+	icons.put(prio[i],new ImageIcon(loadIcon("icons/GreenFlag.gif")));
+    }
+  }
+
+  public void append(LoggingEvent event) {
+    String text = this.layout.format(event);
+    String trace="";
+    // Print Stacktrace
+    // Quick Hack maybe there is a better/faster way?
+    if (event.throwable!=null) {
+      event.throwable.printStackTrace(tp);
+      for (int i=0; i< sw.getBuffer().length(); i++) {
+	if (sw.getBuffer().charAt(i)=='\t')
+	  sw.getBuffer().replace(i,i+1,"        ");
+      }
+      trace = sw.toString();
+      sw.getBuffer().delete(0,sw.getBuffer().length());
+    }
+    try {
+      if (fancy) {
+	textpane.setEditable(true);
+	textpane.insertIcon((ImageIcon)icons.get(event.priority));
+	textpane.setEditable(false);
+      }
+      doc.insertString(doc.getLength(),text+trace,
+		       (MutableAttributeSet)attributes.get(event.priority));
+	}	
+    catch (BadLocationException badex) {
+      System.err.println(badex);
+    }	
+    textpane.setCaretPosition(doc.getLength());
+  }
+  
+  public
+  JTextPane getTextPane() {
+    return textpane;
+  }
+  
+  private
+  static
+  Color parseColor (String v) {
+    StringTokenizer st = new StringTokenizer(v,",");
+    int val[] = {255,255,255,255};
+    int i=0;
+    while (st.hasMoreTokens()) {
+      val[i]=Integer.parseInt(st.nextToken());
+      i++;
+    }
+    return new Color(val[0],val[1],val[2],val[3]);
+  }
+  
+  private
+  static
+  String colorToString(Color c) {
+    // alpha component emitted only if not default (255)
+    String res = ""+c.getRed()+","+c.getGreen()+","+c.getBlue();
+    return c.getAlpha() >= 255 ? res : res + ","+c.getAlpha();
+  }
+
+  public
+  void setLayout(Layout layout) {
+    this.layout=layout;
+  }
+  
+  public
+  void setName(String name) {
+    this.name = name;
+  }
+  
+    
+  public
+  void setTextPane(JTextPane textpane) {
+    this.textpane=textpane;
+    textpane.setEditable(false);
+    textpane.setBackground(Color.lightGray);
+    this.doc=textpane.getStyledDocument();
+  }
+          
+  private
+  void setColor(Priority p, String v) {
+    StyleConstants.setForeground(
+		      (MutableAttributeSet)attributes.get(p),parseColor(v));	
+  }
+  
+  private
+  String getColor(Priority p) {
+    Color c =  StyleConstants.getForeground(
+		      (MutableAttributeSet)attributes.get(p));
+    return c == null ? null : colorToString(c);
+  }
+  
+  /////////////////////////////////////////////////////////////////////
+  // option setters and getters
+  
+  public
+  void setLabel(String label) {
+    this.label = label;
+  }
+  public
+  String getLabel() {
+    return label;
+  }
+  
+  public
+  void setColorEmerg(String color) {
+    setColor(Priority.FATAL, color);
+  }
+  public
+  String getColorEmerg() {
+    return getColor(Priority.FATAL);
+  }
+  
+  public
+  void setColorError(String color) {
+    setColor(Priority.ERROR, color);
+  }
+  public
+  String getColorError() {
+    return getColor(Priority.ERROR);
+  }
+  
+  public
+  void setColorWarn(String color) {
+    setColor(Priority.WARN, color);
+  }
+  public
+  String getColorWarn() {
+    return getColor(Priority.WARN);
+  }
+  
+  public
+  void setColorInfo(String color) {
+    setColor(Priority.INFO, color);
+  }
+  public
+  String getColorInfo() {
+    return getColor(Priority.INFO);
+  }
+  
+  public
+  void setColorDebug(String color) {
+    setColor(Priority.DEBUG, color);
+  }
+  public
+  String getColorDebug() {
+    return getColor(Priority.DEBUG);
+  }
+  
+  public
+  void setColorBackground(String color) {
+    textpane.setBackground(parseColor(color));
+  }
+  public
+  String getColorBackground() {
+    return colorToString(textpane.getBackground());
+  }
+  
+  public
+  void setFancy(boolean fancy) {
+    this.fancy = fancy;
+  }
+  public
+  boolean getFancy() {
+    return fancy;
+  }
+  
+  public
+  void setFontSize(int size) {
+    Enumeration e = attributes.elements();
+    while (e.hasMoreElements()) {
+      StyleConstants.setFontSize((MutableAttributeSet)e.nextElement(),size);
+    }
+    return;
+  }
+  
+  public
+  int getFontSize() {
+    AttributeSet attrSet = (AttributeSet) attributes.get(Priority.INFO);
+    return StyleConstants.getFontSize(attrSet);
+  }
+  
+  public
+  void setFontName(String name) {
+    Enumeration e = attributes.elements();
+    while (e.hasMoreElements()) {
+      StyleConstants.setFontFamily((MutableAttributeSet)e.nextElement(),name);
+    }
+    return;
+  }
+  
+  public
+  String getFontName() {
+    AttributeSet attrSet = (AttributeSet) attributes.get(Priority.INFO);
+    return StyleConstants.getFontFamily(attrSet);
+  }
+
+  public
+  boolean requiresLayout() {
+    return true;
+  }
+} // TextPaneAppender
+
+
+

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/TextPaneAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/TextPanelAppender.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/TextPanelAppender.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/TextPanelAppender.java (added)
+++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/TextPanelAppender.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,215 @@
+/*
+ * 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.log4j.gui;
+
+
+import java.awt.Color;
+import java.awt.Image;
+import java.awt.Toolkit;
+import java.io.*;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.Hashtable;
+import java.util.ArrayList;
+
+import javax.swing.JPanel;
+
+import org.apache.log4j.*;
+
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.helpers.Loader;
+import org.apache.log4j.helpers.QuietWriter;
+import org.apache.log4j.helpers.TracerPrintWriter;
+import org.apache.log4j.helpers.OptionConverter;
+
+/**
+ *
+ * @author James House
+ */
+public class TextPanelAppender extends AppenderSkeleton {
+
+  TracerPrintWriter tp;
+  StringWriter sw;
+  QuietWriter qw;
+  LogTextPanel logTextPanel;
+  LogPublishingThread logPublisher;
+
+  final String COLOR_OPTION_FATAL = "Color.Fatal";
+  final String COLOR_OPTION_ERROR = "Color.Error";
+  final String COLOR_OPTION_WARN = "Color.Warn";
+  final String COLOR_OPTION_INFO = "Color.Info";
+  final String COLOR_OPTION_DEBUG = "Color.Debug";
+  final String COLOR_OPTION_BACKGROUND = "Color.Background";
+  final String FONT_NAME_OPTION = "Font.Name";
+  final String FONT_SIZE_OPTION = "Font.Size";
+  final String EVENT_BUFFER_SIZE_OPTION = "EventBuffer.Size";
+
+  public TextPanelAppender(Layout layout, String name) {
+    this.layout = layout;
+    this.name = name;
+    this.sw = new StringWriter();
+    this.qw = new QuietWriter(sw, errorHandler);
+    this.tp = new TracerPrintWriter(qw);
+    setLogTextPanel(new LogTextPanel());
+    logPublisher = new LogPublishingThread(logTextPanel, Priority.ERROR, 500);
+    //logPublisher = new LogPublishingThread(logTextPanel, null, 500);
+  }
+
+  public
+  void close() {
+  }
+
+  public void append(LoggingEvent event) {
+
+    String text = this.layout.format(event);
+
+    // Print Stacktrace
+    // Quick Hack maybe there is a better/faster way?
+    if (event.throwable!=null) {
+      event.throwable.printStackTrace(tp);
+      for (int i=0; i< sw.getBuffer().length(); i++) {
+        if (sw.getBuffer().charAt(i)=='\t')
+          sw.getBuffer().replace(i,i+1,"        ");
+      }
+      text += sw.toString();
+      sw.getBuffer().delete(0,sw.getBuffer().length());
+    }
+    else
+      if(!text.endsWith("\n"))
+        text += "\n";
+
+    logPublisher.publishEvent(event.priority, text);
+  }
+
+  public
+  JPanel getLogTextPanel() {
+    return logTextPanel;
+  }
+
+  public
+  String[] getOptionStrings() {
+    return new String[] { COLOR_OPTION_FATAL, COLOR_OPTION_ERROR,
+         COLOR_OPTION_WARN, COLOR_OPTION_INFO, COLOR_OPTION_DEBUG,
+         COLOR_OPTION_BACKGROUND, FONT_NAME_OPTION, FONT_SIZE_OPTION};
+  }
+
+
+  public
+  void setName(String name) {
+    this.name = name;
+  }
+
+  protected
+  void setLogTextPanel(LogTextPanel logTextPanel) {
+    this.logTextPanel = logTextPanel;
+    logTextPanel.setTextBackground(Color.white);
+  }
+
+  public
+  void setOption(String option, String value) {
+    if (option.equalsIgnoreCase(COLOR_OPTION_FATAL))
+      logTextPanel.setTextColor(Priority.FATAL,value);
+    if (option.equalsIgnoreCase(COLOR_OPTION_ERROR))
+      logTextPanel.setTextColor(Priority.ERROR,value);
+    if (option.equalsIgnoreCase(COLOR_OPTION_WARN))
+      logTextPanel.setTextColor(Priority.WARN,value);
+    if (option.equalsIgnoreCase(COLOR_OPTION_INFO))
+      logTextPanel.setTextColor(Priority.INFO,value);
+    if (option.equalsIgnoreCase(COLOR_OPTION_DEBUG))
+      logTextPanel.setTextColor(Priority.DEBUG,value);
+    if (option.equalsIgnoreCase(COLOR_OPTION_BACKGROUND))
+      logTextPanel.setTextBackground(value);
+    if (option.equalsIgnoreCase(FONT_SIZE_OPTION))
+      logTextPanel.setTextFontSize(Integer.parseInt(value));
+    if (option.equalsIgnoreCase(FONT_NAME_OPTION))
+      logTextPanel.setTextFontName(value);
+    if (option.equalsIgnoreCase(EVENT_BUFFER_SIZE_OPTION))
+      logTextPanel.setEventBufferSize(Integer.parseInt(value));
+    return;
+  }
+
+  public
+  boolean requiresLayout() {
+    return true;
+  }
+
+
+
+  class LogPublishingThread extends Thread {
+
+    LogTextPanel logTextPanel;
+    ArrayList evts;
+    Priority triggerPrio;
+    long pubInterval;
+
+    public LogPublishingThread(LogTextPanel logTextPanel, Priority triggerPrio, long pubInterval) {
+      this.logTextPanel = logTextPanel;
+      this.evts = new ArrayList(1000);
+      this.triggerPrio = triggerPrio;
+      this.pubInterval = pubInterval;
+      //this.setPriority(Thread.NORM_PRIORITY - 1);
+      this.start();
+    }
+
+    public void run() {
+      while(true) {
+        synchronized(evts) {
+          try {
+            evts.wait(pubInterval);
+          }
+          catch(InterruptedException e) {}
+
+          logTextPanel.newEvents((EventBufferElement[])evts.toArray(new EventBufferElement[evts.size()]));
+
+          evts.clear();
+        }
+      }
+
+    }
+
+    public void publishEvent(Priority prio, String text) {
+      synchronized(evts) {
+        evts.add(new EventBufferElement(prio, text));
+        if(triggerPrio != null && prio.isGreaterOrEqual(triggerPrio))
+          evts.notify();
+      }
+    }
+  }
+
+} // TextPaneAppender
+
+class EventBufferElement {
+
+  public String text;
+  public Priority prio;
+  public int numLines;
+
+  EventBufferElement(Priority prio, String text) {
+    this.prio = prio;
+    this.text = text;
+    numLines = 1;
+    int pos = pos = text.indexOf('\n', 0);
+    int len = text.length() - 1;
+
+    while( (pos > 0) && (pos < len) )
+      numLines++;
+      pos = text.indexOf('\n', pos + 1);
+  }
+}
+
+

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/TextPanelAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/examples/LogTextPanelExample.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/examples/LogTextPanelExample.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/examples/LogTextPanelExample.java (added)
+++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/examples/LogTextPanelExample.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,135 @@
+/*
+ * 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.log4j.gui.examples;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+
+import org.apache.log4j.*;
+import org.apache.log4j.gui.TextPanelAppender;
+
+/**
+ * @author James House
+ */
+public class LogTextPanelExample {
+  boolean packFrame = false;
+
+  String catName = "dum.cat.name";
+
+  public LogTextPanelExample() {
+
+    // setup the logging
+    TextPanelAppender tpa = new TextPanelAppender(new PatternLayout("%-5p %d [%t]:  %m%n"), "logTextPanel");
+    tpa.setThreshold(Priority.DEBUG);
+    Category cat = Category.getInstance(catName);
+    cat.addAppender(tpa);
+
+    LogFrame frame = new LogFrame(tpa);
+    frame.validate();
+
+    //Center the frame (window), and show it
+    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+    Dimension frameSize = frame.getSize();
+    if (frameSize.height > screenSize.height) {
+      frameSize.height = screenSize.height;
+    }
+    if (frameSize.width > screenSize.width) {
+      frameSize.width = screenSize.width;
+    }
+    frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
+    frame.setVisible(true);
+  }
+
+  /**Main method*/
+  public static void main(String[] args) {
+    try {
+      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+    }
+    catch(Exception e) {
+      e.printStackTrace();
+    }
+    LogTextPanelExample foo = new LogTextPanelExample();
+    new LogTextPanelExampleGenThread(foo.catName);
+  }
+}
+
+class LogFrame extends JFrame {
+
+  public LogFrame(TextPanelAppender tpa) {
+    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
+    JPanel contentPane = (JPanel) this.getContentPane();
+    contentPane.setLayout(new BorderLayout());
+    this.setSize(new Dimension(600, 400));
+    this.setTitle("LogTextPanel Example");
+    contentPane.add(tpa.getLogTextPanel(), BorderLayout.CENTER);
+  }
+
+  // exit when window is closed
+  protected void processWindowEvent(WindowEvent e) {
+    super.processWindowEvent(e);
+    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
+      System.exit(0);
+    }
+  }
+}
+
+class LogTextPanelExampleGenThread extends Thread {
+
+  String catName;
+
+  public LogTextPanelExampleGenThread(String catName) {
+    this.catName = catName;
+    this.setPriority(Thread.NORM_PRIORITY - 1);
+    this.start();
+  }
+
+  public void run() {
+    Category cat = Category.getInstance(catName);
+    int cnt = 0;
+    while(true) {
+      cnt++;
+      int randEvt = (int)(Math.random() * 125);
+      if(randEvt < 3)
+        cat.fatal("{" + cnt + "} Something screwed up bad.");
+      else if(randEvt < 10)
+        cat.error("{" + cnt + "} An error occured while trying to delete all of your files.");
+      else if(randEvt < 25)
+        cat.warn("{" + cnt + "} It seems as if your hard disk is getting full.");
+      else if(randEvt < 55)
+        cat.info("{" + cnt + "} It is now time for tea.");
+      else if(randEvt < 65)
+        cat.debug("{" + cnt + "} Something bad is happening on line 565 of com.foo.Crap");
+      else if(randEvt < 75)
+        cat.debug("{" + cnt + "} Input value for xe343dd is not equal to xe39dfd!");
+      else if(randEvt < 85)
+        cat.debug("{" + cnt + "} Successfully reached line 2312 of com.foo.Goo");
+      else if(randEvt < 105)
+        cat.debug("{" + cnt + "} Here is some extra handy debugging information for you.");
+      else if(randEvt < 115)
+        cat.debug("{" + cnt + "} The file you are about to write to is not open.");
+      else if(randEvt < 125)
+        cat.debug("{" + cnt + "} The input value to the method was <null>.");
+
+      try {
+        Thread.sleep(10);
+      }
+      catch(Exception e) {}
+
+    }
+  }
+}
\ No newline at end of file

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/examples/LogTextPanelExample.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/examples/TextPaneAppenderExample.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/examples/TextPaneAppenderExample.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/examples/TextPaneAppenderExample.java (added)
+++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/examples/TextPaneAppenderExample.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,111 @@
+/*
+ * 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.log4j.gui.examples;
+
+import java.awt.event.*;
+import javax.swing.*;
+import org.apache.log4j.*;
+import org.apache.log4j.gui.*;
+
+/**
+ * @author Sven Reimers
+ */
+public class TextPaneAppenderExample implements ActionListener {
+
+    JFrame mainframe;
+    ButtonGroup priorities;
+    TextPaneAppender tpa;
+    Category gui;
+    Priority prio[];
+    JTabbedPane logview;
+    
+    
+    public TextPaneAppenderExample () {
+	mainframe = new JFrame("Testing the TextPaneAppender...");
+	mainframe.setSize(300,300);
+	logview = new JTabbedPane();
+	createLogger();
+	createMenuBar();
+	mainframe.setVisible(true);
+	mainframe.getContentPane().add(logview);
+    }
+
+    public void createLogger() {
+	tpa = new TextPaneAppender(new PatternLayout("%-5p %d [%t]:  %m%n"),"Debug");
+	logview.addTab("Events ...",new JScrollPane(tpa.getTextPane()));
+	gui = Category.getInstance(this.getClass().getName());
+	gui.addAppender(tpa);
+    }
+    
+    public void createMenuBar() {
+	JMenu file = new JMenu("File");
+	JMenuItem exit = new JMenuItem("Exit");
+	exit.addActionListener(new ActionListener() {
+		public void actionPerformed(ActionEvent ae) {
+		    System.exit(0);
+		}
+	    });
+	file.add(exit);
+	JMenuBar mb = new JMenuBar();
+	mb.add(file);
+	
+	JMenu logevent = new JMenu("LoggingEvents");
+	JMenu selectprio = new JMenu("Priority");
+	
+	prio = Priority.getAllPossiblePriorities();
+	JRadioButtonMenuItem priority[]= new JRadioButtonMenuItem[prio.length];
+	priorities = new ButtonGroup();
+	
+	for (int i=0; i<prio.length;i++) {
+	    if (i==0)
+		priority[i] = new JRadioButtonMenuItem(prio[i].toString(),true);
+	    else
+		priority[i] = new JRadioButtonMenuItem(prio[i].toString());
+	    priority[i].setActionCommand(prio[i].toString());
+	    selectprio.add(priority[i]);
+	    priorities.add(priority[i]);
+
+	}
+	
+	logevent.add(selectprio);
+	
+	JMenuItem lognow = new JMenuItem("LogIt!");
+	lognow.addActionListener(this);
+	logevent.add(lognow);
+	
+	mb.add(logevent);
+	
+	mainframe.setJMenuBar(mb);
+	
+    }
+    
+    public void actionPerformed(ActionEvent ae){
+	String logtext = JOptionPane.showInputDialog("Text to log");
+	if (logtext == null) logtext="NO Input";
+	int i=0;
+	String name = priorities.getSelection().getActionCommand();
+	while (!prio[i].toString().equals(name))
+	    i=i+1;
+	gui.log(prio[i],logtext);
+    }
+
+    static public void main(String args[]) {
+	TextPaneAppenderExample tpex = new TextPaneAppenderExample();
+    }
+    
+}

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/gui/examples/TextPaneAppenderExample.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/helpers/SingleLineTracerPrintWriter.java (from r1345481, logging/log4j/branches/log4j12modules/contribs/KitchingSimon/SingleLineTracerPrintWriter.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/helpers/SingleLineTracerPrintWriter.java?p2=logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/helpers/SingleLineTracerPrintWriter.java&p1=logging/log4j/branches/log4j12modules/contribs/KitchingSimon/SingleLineTracerPrintWriter.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/helpers/SingleLineTracerPrintWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/helpers/SingleLineTracerPrintWriter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/DatagramStringAppender.java (from r1345481, logging/log4j/branches/log4j12modules/contribs/KitchingSimon/DatagramStringAppender.java)
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/DatagramStringAppender.java?p2=logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/DatagramStringAppender.java&p1=logging/log4j/branches/log4j12modules/contribs/KitchingSimon/DatagramStringAppender.java&r1=1345481&r2=1345492&rev=1345492&view=diff
==============================================================================
    (empty)

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/DatagramStringAppender.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/DatagramStringAppender.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/PluggableHTTPServer.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/PluggableHTTPServer.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/PluggableHTTPServer.java (added)
+++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/PluggableHTTPServer.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,262 @@
+/*
+ * 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.log4j.net;
+
+import java.net.*;
+import java.io.*;
+import java.util.*;
+import org.apache.log4j.*;
+
+/**
+ * This class implements a HTTP-server frame. All HTTP-requests are handled by HTTPRequestHandler
+ * classes which implement the <code>HTTPRequestHandler</code> interface. Every RequestHandler has
+ * to be registered in the PluggableHTTPServer with the <code>addRequestHandler</code> method.
+ * A new thread is created for each connection to handle the request. If all reply data are sent
+ * to the client the connection is closed and the thread ends.
+ * An example how to use the PluggableHTTPServer class can be found in the <code>main</code> method
+ * at the end of the source file.
+ *
+ * @author <a HREF="mailto:V.Mentzner@psi-bt.de">Volker Mentzner</a>
+ */
+public class PluggableHTTPServer implements Runnable {
+
+  public static final int DEFAULT_PORT = 80;
+  static Category cat = Category.getInstance("PluggableHTTPServer");
+  private int port;
+  private Vector handler;
+  private ServerSocket server;
+
+  /**
+   * Creates a new server object on the given TCP port.
+   * If the port is occupied by another process a IOException (java.net.BindException) is thrown.
+   *
+   * @param port - TCP port number to listen on for requests
+   */
+  public PluggableHTTPServer(int port) throws IOException {
+    this.port = port;
+    this.handler = new Vector();
+    cat.setPriority(Priority.ERROR);
+    server = new ServerSocket(this.port);
+  }
+
+  /**
+   * Creates a new server object on the default TCP port 80
+   * If the port is occupied by another process a IOException (java.net.BindException) is thrown.
+   */
+  public PluggableHTTPServer() throws IOException {
+    this(DEFAULT_PORT);
+  }
+
+  /**
+   * Registers the given HTTPRequestHandler
+   *
+   * @param h - the HTTPRequestHandler to register
+   */
+  public void addRequestHandler(HTTPRequestHandler h) {
+    handler.add(h);
+  }
+
+  /**
+   * Unregisters the given HTTPRequestHandler
+   *
+   * @param h - the HTTPRequestHandler to unregister
+   */
+  public void removeRequestHandler(HTTPRequestHandler h) {
+    handler.remove(h);
+  }
+
+  /**
+   * Sends the HTTP message 404 - File Not Found
+   * see RFC2616 for details
+   *
+   * @param out - Out stream for sending data to client browser
+   */
+  public static void replyNotFound(Writer out) {
+    try {
+      out.write("HTTP/1.0 404 Not Found\r\n");
+      out.write("<HTML><HEAD><TITLE>Not Found</TITLE></HEAD>\r\n");
+      out.write("<BODY><H1>Not Found</H1>\r\n");
+      out.write("</BODY></HTML>\r\n");
+      out.flush();
+    }  // end try
+    catch (IOException e) {
+    }
+  }
+
+  /**
+   * Sends the HTTP message 405 - Method Not Allowed
+   * see RFC2616 for details
+   *
+   * @param out - Out stream for sending data to client browser
+   */
+  public static void replyMethodNotAllowed(Writer out) {
+    try {
+      out.write("HTTP/1.1 405 Method Not Allowed\r\n");
+      out.write("Allow: GET, PUT\r\n");
+      out.write("<HTML><HEAD><TITLE>Method Not Allowed</TITLE></HEAD>\r\n");
+      out.write("<BODY><H1>Method Not Allowed</H1>\r\n");
+      out.write("</BODY></HTML>\r\n");
+      out.flush();
+    }  // end try
+    catch (IOException e) {
+    }
+  }
+
+  /**
+   * Creates the ReplyHTML data for the root page
+   *
+   * @param index - index of the RootRequestHandler
+   */
+  public void autoCreateRootPage(int index) {
+    if (handler.get(index) instanceof RootRequestHandler) {
+      RootRequestHandler r = (RootRequestHandler)handler.get(index);
+      String html = "<HTML><HEAD><TITLE>"+r.getTitle()+"</TITLE></HEAD>\r\n";
+      html = html + "<BODY><H1>"+r.getDescription()+"</H1>\r\n";
+      for (int i = 0; i < handler.size(); i++) {
+        html = html + "<a href=\"" + ((HTTPRequestHandler)handler.get(i)).getHandledPath();
+        html = html + "\">" + ((HTTPRequestHandler)handler.get(i)).getDescription() + "</a><br>";
+      }
+      html = html + "</BODY></HTML>\r\n";
+      r.setReplyHTML(html);
+    }
+  }
+
+  /**
+   * Main loop of the PluggableHTTPServer
+   */
+  public void run() {
+    while (true) {
+      try {
+        Socket s = server.accept();
+        Thread t = new ServerThread(s);
+        t.start();
+      }
+      catch (IOException e) {
+      }
+    }
+  }
+
+  /**
+   * This class handles the incomming connection for one request.
+   */
+  class ServerThread extends Thread {
+
+    private Socket connection;
+
+    ServerThread(Socket s) {
+      this.connection = s;
+    }
+
+    /**
+     * Serves the HTTP request.
+     */
+    public void run() {
+      try {
+        Writer out = new BufferedWriter(
+                      new OutputStreamWriter(
+                       connection.getOutputStream(), "ASCII"
+                      )
+                     );
+        Reader in = new InputStreamReader(
+                     new BufferedInputStream(
+                      connection.getInputStream()
+                     )
+                    );
+
+        // read the first line only; that's all we need
+        StringBuffer req = new StringBuffer(80);
+        while (true) {
+          int c = in.read();
+          if (c == '\r' || c == '\n' || c == -1) break;
+          req.append((char) c);
+        }
+        String get = req.toString();
+        cat.debug(get);
+        StringTokenizer st = new StringTokenizer(get);
+        String method = st.nextToken();
+        String request = st.nextToken();
+        String version = st.nextToken();
+
+        if (method.equalsIgnoreCase("GET")) {
+          boolean served = false;
+          for (int i = 0; i < handler.size(); i++) {
+            if (handler.get(i) instanceof HTTPRequestHandler) {
+              if (((HTTPRequestHandler)handler.get(i)).handleRequest(request, out)) {
+                served = true;
+                break;
+              }
+            }
+          }
+          if (!served)
+            PluggableHTTPServer.replyNotFound(out);
+        }
+        else {
+          PluggableHTTPServer.replyMethodNotAllowed(out);
+        }
+      } // end try
+      catch (IOException e) {
+      }
+      finally {
+        try {
+          if (connection != null) connection.close();
+        }
+        catch (IOException e) {}
+      }
+    }  // end run
+  }  // end class ServerThread
+
+  /**
+   * Demo how to use the PluggableHTTPServer.
+   */
+  public static void main(String[] args) {
+
+    int thePort;
+
+    // create some logging stuff
+    BasicConfigurator.configure();
+    Category cat1 = Category.getInstance("cat1");
+    cat1.addAppender(new org.apache.log4j.ConsoleAppender(new PatternLayout("%m%n")));
+    Category cat2 = Category.getInstance("cat2");
+    cat2.setPriority(Priority.INFO);
+    cat2.addAppender(new org.apache.log4j.ConsoleAppender(new PatternLayout("%c - %m%n")));
+
+    // set TCP port number
+    try {
+      thePort = Integer.parseInt(args[1]);
+    }
+    catch (Exception e) {
+      thePort = PluggableHTTPServer.DEFAULT_PORT;
+    }
+
+    PluggableHTTPServer server = null;
+    while (server == null) {
+      try {
+        server = new PluggableHTTPServer(thePort);
+        server.addRequestHandler(new RootRequestHandler());
+        server.addRequestHandler(new Log4jRequestHandler());
+        server.addRequestHandler(new UserDialogRequestHandler());
+        server.autoCreateRootPage(0);
+        Thread t = new Thread(server);
+        t.start();
+      } catch (IOException e) {
+        server = null;
+        thePort++;
+      }
+    }
+
+  }  // end main
+}

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/PluggableHTTPServer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/SocketNode2.java
URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/SocketNode2.java?rev=1345492&view=auto
==============================================================================
--- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/SocketNode2.java (added)
+++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/SocketNode2.java Sat Jun  2 11:40:31 2012
@@ -0,0 +1,118 @@
+/*
+ * 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.log4j.net;
+
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.ServerSocket;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+
+
+import org.apache.log4j.Category;
+import org.apache.log4j.spi.LoggingEvent;
+import org.apache.log4j.Priority;
+import org.apache.log4j.NDC;
+
+// Contributors:  Moses Hohman <mmhohman@rainbow.uchicago.edu>
+
+/**
+   Read {@link LoggingEvent} objects sent from a remote client using
+   Sockets (TCP). These logging events are logged according to local
+   policy, as if they were generated locally.
+
+   <p>For example, the socket node might decide to log events to a
+   local file and also resent them to a second socket node.
+
+	@author  Ceki G&uuml;lc&uuml;
+
+	@since 0.8.4
+*/
+public class SocketNode2 implements Runnable {
+
+  Socket socket;
+  ObjectInputStream ois;
+
+  static Category cat = Category.getInstance(SocketNode2.class.getName());
+
+  public
+  SocketNode2(Socket socket) {
+	this.socket = socket;
+	try {
+	  ois = new ObjectInputStream(socket.getInputStream());
+	}
+	catch(Exception e) {
+	  cat.error("Could not open ObjectInputStream to "+socket, e);
+	}
+  }
+
+  //public
+  //void finalize() {
+  //System.err.println("-------------------------Finalize called");
+  // System.err.flush();
+  //}
+
+  public void run() {
+	LoggingEvent event;
+	Category remoteCategory;
+	String strClientName;
+
+	// Get the client name.
+	InetAddress addr = socket.getInetAddress();
+	strClientName = addr.getHostName();
+	if(strClientName == null || strClientName.length() == 0)
+	{
+		strClientName = addr.getHostAddress();
+	}
+
+	try {
+	  while(true) {
+	event = (LoggingEvent) ois.readObject();
+
+	if(event.ndc != null)
+	{
+		event.ndc = strClientName + ":" + event.ndc;
+	}
+	else
+	{
+		event.ndc = strClientName;
+	}
+
+	remoteCategory = Category.getInstance(event.categoryName);
+	remoteCategory.callAppenders(event);
+	  }
+	}
+	catch(java.io.EOFException e) {
+	  cat.info("Caught java.io.EOFException will close conneciton.", e);
+	}
+	catch(java.net.SocketException e) {
+	  cat.info("Caught java.net.SocketException, will close conneciton.", e);
+	}
+	catch(Exception e) {
+	  cat.error("Unexpected exception. Closing conneciton.", e);
+	}
+
+	try {
+	  ois.close();
+	}
+	catch(Exception e) {
+	  cat.info("Could not close connection.", e);
+	}
+  }
+}

Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/SocketNode2.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message