From commits-return-786-apmail-logging-commits-archive=logging.apache.org@logging.apache.org Sat Jun 2 11:42:54 2012 Return-Path: X-Original-To: apmail-logging-commits-archive@minotaur.apache.org Delivered-To: apmail-logging-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E8792CE74 for ; Sat, 2 Jun 2012 11:42:54 +0000 (UTC) Received: (qmail 27279 invoked by uid 500); 2 Jun 2012 11:42:54 -0000 Delivered-To: apmail-logging-commits-archive@logging.apache.org Received: (qmail 27245 invoked by uid 500); 2 Jun 2012 11:42:54 -0000 Mailing-List: contact commits-help@logging.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@logging.apache.org Delivered-To: mailing list commits@logging.apache.org Received: (qmail 27228 invoked by uid 99); 2 Jun 2012 11:42:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jun 2012 11:42:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Jun 2012 11:42:39 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C9A952388C52; Sat, 2 Jun 2012 11:41:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1345492 [12/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 -0000 To: commits@logging.apache.org From: grobmeier@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120602114143.C9A952388C52@eris.apache.org> Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/SocketServer2.java URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/SocketServer2.java?rev=1345492&view=auto ============================================================================== --- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/SocketServer2.java (added) +++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/SocketServer2.java Sat Jun 2 11:40:31 2012 @@ -0,0 +1,99 @@ +/* + * 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.Socket; +import java.net.ServerSocket; +import java.io.IOException; + +import org.apache.log4j.Category; +import org.apache.log4j.PropertyConfigurator; +import org.apache.log4j.NDC; + +/** + A simple {@link SocketNode} based server. + +
+	 Usage: java org.apache.log4j.net.SocketServer port configFile
+
+	 where port is a part number where the server listens and
+	 configFile is a configuration file fed to the {@link
+	 PropertyConfigurator}.
+   
+ + + + + + @author Ceki Gülcü + + @since 0.8.4 */ + +public class SocketServer2 { + + static Category cat = Category.getInstance(SocketServer2.class.getName()); + + static int port; + + public + static + void main(String argv[]) { + if(argv.length == 2) + init(argv[0], argv[1]); + else + usage("Wrong number of arguments."); + + try { + cat.info("Listening on port " + port); + ServerSocket serverSocket = new ServerSocket(port); + while(true) { + cat.info("Waiting to accept a new client."); + Socket socket = serverSocket.accept(); + cat.info("Connected to client at " + socket.getInetAddress()); + cat.info("Starting new socket node."); + new Thread(new SocketNode2(socket)).start(); + } + } + catch(Exception e) { + e.printStackTrace(); + } + } + + + static + void usage(String msg) { + System.err.println(msg); + System.err.println( + "Usage: java " + SocketServer2.class.getName() + " port configFile"); + System.exit(1); + } + + static + void init(String portStr, String configFile) { + try { + port = Integer.parseInt(portStr); + } + catch(java.lang.NumberFormatException e) { + e.printStackTrace(); + usage("Could not interpret port number ["+ portStr +"]."); + } + PropertyConfigurator.configure(configFile); + NDC.push("Server"); + } +} Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/SocketServer2.java ------------------------------------------------------------------------------ svn:eol-style = native Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/UserDialogRequestHandler.java URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/UserDialogRequestHandler.java?rev=1345492&view=auto ============================================================================== --- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/UserDialogRequestHandler.java (added) +++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/UserDialogRequestHandler.java Sat Jun 2 11:40:31 2012 @@ -0,0 +1,140 @@ +/* + * 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. + */ +/** + * Title: PSI Java Framework: UserDialogRequestHandler

+ * Copyright: PSI-BT AG

+ * History: + * Date Author What's new + * 16.04.2001 VMentzner Created + */ + +package org.apache.log4j.net; + +import java.awt.Component; +import java.io.Writer; +import java.net.URL; + +/** + * This class implements a RequestHandler for the path "/userdialog/" in the PluggableHTTPServer. + * A simple input form is presented in the browser where you can enter a message. This message will be sent + * to the PluggableHTTPServer and shown in a JOptionPane MessageDialog. + * + * @author Volker Mentzner + */ +public class UserDialogRequestHandler extends RootRequestHandler { + + private Component parentComponent; + + /** + * Creates a new UserDialogRequestHandler object + */ + public UserDialogRequestHandler() { + this(null); + } + + /** + * Creates a new UserDialogRequestHandler object with a parentComponent reference + */ + public UserDialogRequestHandler(Component parentComponent) { + this.setTitle("user dialog"); + this.setDescription("show user dialog"); + this.setHandledPath("/userdialog/"); + this.parentComponent = parentComponent; + } + + /** + * 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.getQuery(); + if (path.startsWith(this.getHandledPath()) == false) { + return false; + } + + out.write("HTTP/1.0 200 OK\r\n"); + out.write("Content-type: text/html\r\n\r\n"); + out.write("" + this.getTitle() + "\r\n"); + out.write("

" + this.getDescription() + "

\r\n"); + if ((query != null) && (query.length() >= 0)) { + int idx = query.indexOf("="); + String message = query.substring(idx+1, query.length()); + // replace '+' by space + message = message.replace('+', ' '); + // replace hex strings starting with '%' by their values + idx = message.indexOf("%"); + while (idx >= 0) { + String sl = message.substring(0, idx); + String sm = message.substring(idx+1, idx+3); + String sr = message.substring(idx+3, message.length()); + try { + int i = Integer.parseInt(sm, 16); + sm = String.valueOf((char)i); + } + catch (Exception ex) { + sm = ""; + } + message = sl + sm + sr; + idx = message.indexOf("%"); + } + // show message in a new thread + if ((message != null) && (message.length() > 0)) { + Thread t = new Thread(new DialogThread(parentComponent, message)); + t.start(); + } + } + out.write("
"); + out.write("\r\n"); + out.write(" \r\n"); + out.write(" \r\n"); + out.write("
Send message to user
\r\n"); + out.write(""); + out.write("
"); + out.write("\r\n"); + out.flush(); + return true; + } catch (Exception ex) { + return false; + } + } + + /** + * Internal class to start the user dialog in a new thread. This makes the RequestHandler return + * immediatly + */ + class DialogThread implements Runnable { + private Component parentComponent; + private String message; + + public DialogThread(Component parentComponent, String message) { + this.parentComponent = parentComponent; + this.message = message; + } + + public void run() { + JOptionPane.showMessageDialog(parentComponent, message); + } + } +} \ No newline at end of file Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/net/UserDialogRequestHandler.java ------------------------------------------------------------------------------ svn:eol-style = native Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/varia/test/JDBCTest.java URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/varia/test/JDBCTest.java?rev=1345492&view=auto ============================================================================== --- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/varia/test/JDBCTest.java (added) +++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/varia/test/JDBCTest.java Sat Jun 2 11:40:31 2012 @@ -0,0 +1,98 @@ +/* + * 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.varia.test; + +import org.apache.log4j.*; +import org.apache.log4j.net.JDBCAppender; + +/** + * @author Kevin Sceppe + */ +public class JDBCTest +{ + public static void main (String argv[]) + { + try { + Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); + } + catch (Exception e) + { + e.printStackTrace(); + System.out.println(e.toString()); + } + + + Category rootLog = Category.getRoot(); + Layout layout = new PatternLayout("%p [%t] %c - %m%n"); + JDBCAppender appender = new JDBCAppender(); + appender.setLayout(layout); + appender.setOption(org.apache.log4j.net.URL_OPTION, "jdbc:odbc:someDB"); + + + appender.setOption(org.apache.log4j.net.USER_OPTION, "auser"); + appender.setOption(org.apache.log4j.net.PASSWORD_OPTION, "thepassword"); + + + + rootLog.addAppender(appender); + + + try { + Category log = Category.getInstance("main"); + log.debug("Debug 1"); + Thread.sleep(500); + log.info("info 1"); + Thread.sleep(500); + log.warn("warn 1"); + Thread.sleep(500); + log.error("error 1"); + Thread.sleep(500); + log.fatal("fatal 1"); + Thread.sleep(500); + + + appender.setOption(org.apache.log4j.net.BUFFER_OPTION, "5"); + log.debug("Debug 2"); + Thread.sleep(500); + log.info("info 2"); + Thread.sleep(500); + log.warn("warn 2"); + Thread.sleep(500); + log.error("error 2"); + Thread.sleep(500); + log.fatal("fatal 2"); + Thread.sleep(500); + + + appender.setOption(org.apache.log4j.net.BUFFER_OPTION, "2"); + appender.setThreshold(Priority.WARN); + log.debug("Debug 3"); + Thread.sleep(500); + log.info("info 3"); + Thread.sleep(500); + log.warn("warn 3"); + Thread.sleep(500); + log.error("error 3"); + Thread.sleep(500); + log.fatal("fatal 3"); + } + catch (InterruptedException e) + { + System.out.println("Interrupted"); + } + } +} Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/varia/test/JDBCTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/xml/Transform.java URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/xml/Transform.java?rev=1345492&view=auto ============================================================================== --- logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/xml/Transform.java (added) +++ logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/xml/Transform.java Sat Jun 2 11:40:31 2012 @@ -0,0 +1,221 @@ +/* + * 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.xml; + +import org.apache.log4j.Category; +import org.apache.log4j.Layout; +import org.apache.log4j.PropertyConfigurator; +import org.apache.log4j.spi.LoggingEvent; +import org.apache.log4j.helpers.OptionConverter; +import org.apache.log4j.helpers.DateLayout; + +import org.xml.sax.ContentHandler; +import org.xml.sax.Locator; +import org.xml.sax.Attributes; +import org.xml.sax.XMLReader; +import org.xml.sax.ext.LexicalHandler; +import org.xml.sax.helpers.XMLReaderFactory; +import org.xml.sax.SAXException; +import org.apache.xerces.parsers.SAXParser; + +import org.apache.trax.Processor; +import org.apache.trax.TemplatesBuilder; +import org.apache.trax.Templates; +import org.apache.trax.Transformer; +import org.apache.trax.Result; +import org.apache.trax.ProcessorException; +import org.apache.trax.ProcessorFactoryException; +import org.apache.trax.TransformException; + + +import org.apache.serialize.SerializerFactory; +import org.apache.serialize.Serializer; +import org.apache.serialize.OutputFormat; +import org.xml.sax.helpers.AttributesImpl; + + +import java.io.FileOutputStream; +import java.io.IOException; + +/** + * @author CekiGulcu + */ +public class Transform { + + public static void main(String[] args) throws Exception { + PropertyConfigurator.disableAll(); + PropertyConfigurator.configure("x.lcf"); + + // I. Instantiate a stylesheet processor. + Processor processor = Processor.newInstance("xslt"); + + // II. Process the stylesheet. producing a Templates object. + + // Get the XMLReader. + XMLReader reader = XMLReaderFactory.createXMLReader(); + + // Set the ContentHandler. + TemplatesBuilder templatesBuilder = processor.getTemplatesBuilder(); + reader.setContentHandler(templatesBuilder); + + // Set the ContentHandler to also function as a LexicalHandler, which + // includes "lexical" (e.g., comments and CDATA) events. The Xalan + // TemplatesBuilder -- org.apache.xalan.processor.StylesheetHandler -- is + // also a LexicalHandler). + if(templatesBuilder instanceof LexicalHandler) { + reader.setProperty("http://xml.org/sax/properties/lexical-handler", + templatesBuilder); + } + + // Parse the stylesheet. + reader.parse(args[0]); + + //Get the Templates object from the ContentHandler. + Templates templates = templatesBuilder.getTemplates(); + + // III. Use the Templates object to instantiate a Transformer. + Transformer transformer = templates.newTransformer(); + + // IV. Perform the transformation. + + // Set up the ContentHandler for the output. + FileOutputStream fos = new FileOutputStream(args[2]); + Result result = new Result(fos); + Serializer serializer = SerializerFactory.getSerializer("xml"); + serializer.setOutputStream(fos); + + transformer.setContentHandler(serializer.asContentHandler()); + + // Set up the ContentHandler for the input. + org.xml.sax.ContentHandler chandler = transformer.getInputContentHandler(); + DC dc = new DC(chandler); + reader.setContentHandler(dc); + if(chandler instanceof LexicalHandler) { + reader.setProperty("http://xml.org/sax/properties/lexical-handler", + chandler); + } else { + reader.setProperty("http://xml.org/sax/properties/lexical-handler", + null); + } + + // Parse the XML input document. The input ContentHandler and + // output ContentHandler work in separate threads to optimize + // performance. + reader.parse(args[1]); + } +} + + class DC implements ContentHandler { + + static Category cat = Category.getInstance("DC"); + + ContentHandler chandler; + + DC(ContentHandler chandler) { + this.chandler = chandler; + } + + + public + void characters(char[] ch, int start, int length) + throws org.xml.sax.SAXException { + cat.debug("characters: ["+new String(ch, start, length)+ "] called"); + chandler.characters(ch, start, length); + + } + + public + void endDocument() throws org.xml.sax.SAXException { + cat.debug("endDocument called."); + chandler.endDocument(); + + } + + public + void endElement(String namespaceURI, String localName, String qName) + throws org.xml.sax.SAXException { + cat.debug("endElement("+namespaceURI+", "+localName+", "+qName+") called"); + chandler.endElement(namespaceURI, localName, qName); + } + + public + void endPrefixMapping(String prefix) throws org.xml.sax.SAXException { + cat.debug("endPrefixMapping("+prefix+") called"); + chandler.endPrefixMapping(prefix); + } + + public + void ignorableWhitespace(char[] ch, int start, int length) + throws org.xml.sax.SAXException { + cat.debug("ignorableWhitespace called"); + chandler.ignorableWhitespace(ch, start, length); + } + + public + void processingInstruction(java.lang.String target, java.lang.String data) + throws org.xml.sax.SAXException { + cat.debug("processingInstruction called"); + chandler.processingInstruction(target, data); + } + + public + void setDocumentLocator(Locator locator) { + cat.debug("setDocumentLocator called"); + chandler.setDocumentLocator(locator); + } + + public + void skippedEntity(String name) throws org.xml.sax.SAXException { + cat.debug("skippedEntity("+name+") called"); + chandler.skippedEntity(name); + } + + public + void startDocument() throws org.xml.sax.SAXException { + cat.debug("startDocument called"); + chandler.startDocument(); + } + + public + void startElement(String namespaceURI, String localName, String qName, + Attributes atts) throws org.xml.sax.SAXException { + cat.debug("startElement("+namespaceURI+", "+localName+", "+qName+")called"); + + if("log4j:event".equals(qName)) { + cat.debug("-------------"); + if(atts instanceof org.xml.sax.helpers.AttributesImpl) { + AttributesImpl ai = (AttributesImpl) atts; + int i = atts.getIndex("timestamp"); + ai.setValue(i, "hello"); + } + String ts = atts.getValue("timestamp"); + cat.debug("New timestamp is " + ts); + } + chandler.startElement(namespaceURI, localName, qName, atts); + } + + public + void startPrefixMapping(String prefix, String uri) + throws org.xml.sax.SAXException { + cat.debug("startPrefixMapping("+prefix+", "+uri+") called"); + chandler.startPrefixMapping(prefix, uri); + } + + +} + Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/stale/org/apache/log4j/xml/Transform.java ------------------------------------------------------------------------------ svn:eol-style = native Copied: logging/log4j/branches/log4j12modules/modules/contribs/src/test/resources/org/apache/log4j/contribs/KitchingSimon/logconfig.xml (from r1345481, logging/log4j/branches/log4j12modules/contribs/KitchingSimon/logconfig.xml) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/test/resources/org/apache/log4j/contribs/KitchingSimon/logconfig.xml?p2=logging/log4j/branches/log4j12modules/modules/contribs/src/test/resources/org/apache/log4j/contribs/KitchingSimon/logconfig.xml&p1=logging/log4j/branches/log4j12modules/contribs/KitchingSimon/logconfig.xml&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/test/resources/org/apache/log4j/contribs/KitchingSimon/logconfig.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/test/resources/org/apache/log4j/contribs/KitchingSimon/logconfig.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/contribs/src/test/resources/org/apache/log4j/contribs/KitchingSimon/udpserver.pl (from r1345481, logging/log4j/branches/log4j12modules/contribs/KitchingSimon/udpserver.pl) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/contribs/src/test/resources/org/apache/log4j/contribs/KitchingSimon/udpserver.pl?p2=logging/log4j/branches/log4j12modules/modules/contribs/src/test/resources/org/apache/log4j/contribs/KitchingSimon/udpserver.pl&p1=logging/log4j/branches/log4j12modules/contribs/KitchingSimon/udpserver.pl&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/test/resources/org/apache/log4j/contribs/KitchingSimon/udpserver.pl ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/contribs/src/test/resources/org/apache/log4j/contribs/KitchingSimon/udpserver.pl ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingDefaultConfigurator/InitUsingDefaultConfigurator.java (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/InitUsingDefaultConfigurator/InitUsingDefaultConfigurator.java) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingDefaultConfigurator/InitUsingDefaultConfigurator.java?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingDefaultConfigurator/InitUsingDefaultConfigurator.java&p1=logging/log4j/branches/log4j12modules/examples/lf5/InitUsingDefaultConfigurator/InitUsingDefaultConfigurator.java&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingDefaultConfigurator/InitUsingDefaultConfigurator.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingDefaultConfigurator/InitUsingDefaultConfigurator.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingLog4JProperties/InitUsingLog4JProperties.java (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/InitUsingLog4JProperties/InitUsingLog4JProperties.java) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingLog4JProperties/InitUsingLog4JProperties.java?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingLog4JProperties/InitUsingLog4JProperties.java&p1=logging/log4j/branches/log4j12modules/examples/lf5/InitUsingLog4JProperties/InitUsingLog4JProperties.java&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingLog4JProperties/InitUsingLog4JProperties.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingLog4JProperties/InitUsingLog4JProperties.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingLog4JProperties/log4j.properties (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/InitUsingLog4JProperties/log4j.properties) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingLog4JProperties/log4j.properties?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingLog4JProperties/log4j.properties&p1=logging/log4j/branches/log4j12modules/examples/lf5/InitUsingLog4JProperties/log4j.properties&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingLog4JProperties/log4j.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingLog4JProperties/log4j.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingMultipleAppenders/InitUsingMultipleAppenders.java (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/InitUsingMultipleAppenders/InitUsingMultipleAppenders.java) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingMultipleAppenders/InitUsingMultipleAppenders.java?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingMultipleAppenders/InitUsingMultipleAppenders.java&p1=logging/log4j/branches/log4j12modules/examples/lf5/InitUsingMultipleAppenders/InitUsingMultipleAppenders.java&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingMultipleAppenders/InitUsingMultipleAppenders.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingMultipleAppenders/InitUsingMultipleAppenders.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingMultipleAppenders/example.properties (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/InitUsingMultipleAppenders/example.properties) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingMultipleAppenders/example.properties?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingMultipleAppenders/example.properties&p1=logging/log4j/branches/log4j12modules/examples/lf5/InitUsingMultipleAppenders/example.properties&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingMultipleAppenders/example.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingMultipleAppenders/example.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingPropertiesFile/InitUsingPropertiesFile.java (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/InitUsingPropertiesFile/InitUsingPropertiesFile.java) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingPropertiesFile/InitUsingPropertiesFile.java?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingPropertiesFile/InitUsingPropertiesFile.java&p1=logging/log4j/branches/log4j12modules/examples/lf5/InitUsingPropertiesFile/InitUsingPropertiesFile.java&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingPropertiesFile/InitUsingPropertiesFile.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingPropertiesFile/InitUsingPropertiesFile.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingPropertiesFile/example.properties (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/InitUsingPropertiesFile/example.properties) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingPropertiesFile/example.properties?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingPropertiesFile/example.properties&p1=logging/log4j/branches/log4j12modules/examples/lf5/InitUsingPropertiesFile/example.properties&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingPropertiesFile/example.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingPropertiesFile/example.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingXMLPropertiesFile/InitUsingXMLPropertiesFile.java (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/InitUsingXMLPropertiesFile/InitUsingXMLPropertiesFile.java) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingXMLPropertiesFile/InitUsingXMLPropertiesFile.java?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingXMLPropertiesFile/InitUsingXMLPropertiesFile.java&p1=logging/log4j/branches/log4j12modules/examples/lf5/InitUsingXMLPropertiesFile/InitUsingXMLPropertiesFile.java&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingXMLPropertiesFile/InitUsingXMLPropertiesFile.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingXMLPropertiesFile/InitUsingXMLPropertiesFile.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingXMLPropertiesFile/example.xml (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/InitUsingXMLPropertiesFile/example.xml) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingXMLPropertiesFile/example.xml?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingXMLPropertiesFile/example.xml&p1=logging/log4j/branches/log4j12modules/examples/lf5/InitUsingXMLPropertiesFile/example.xml&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingXMLPropertiesFile/example.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/InitUsingXMLPropertiesFile/example.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingLogMonitorAdapter/CustomizedLogLevels.java (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/UsingLogMonitorAdapter/CustomizedLogLevels.java) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingLogMonitorAdapter/CustomizedLogLevels.java?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingLogMonitorAdapter/CustomizedLogLevels.java&p1=logging/log4j/branches/log4j12modules/examples/lf5/UsingLogMonitorAdapter/CustomizedLogLevels.java&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingLogMonitorAdapter/CustomizedLogLevels.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingLogMonitorAdapter/CustomizedLogLevels.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingLogMonitorAdapter/UsingLogMonitorAdapter.java (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/UsingLogMonitorAdapter/UsingLogMonitorAdapter.java) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingLogMonitorAdapter/UsingLogMonitorAdapter.java?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingLogMonitorAdapter/UsingLogMonitorAdapter.java&p1=logging/log4j/branches/log4j12modules/examples/lf5/UsingLogMonitorAdapter/UsingLogMonitorAdapter.java&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingLogMonitorAdapter/UsingLogMonitorAdapter.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingLogMonitorAdapter/UsingLogMonitorAdapter.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/UsingSocketAppenders.java (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/UsingSocketAppenders/UsingSocketAppenders.java) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/UsingSocketAppenders.java?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/UsingSocketAppenders.java&p1=logging/log4j/branches/log4j12modules/examples/lf5/UsingSocketAppenders/UsingSocketAppenders.java&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/UsingSocketAppenders.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/UsingSocketAppenders.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/socketclient.properties (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/UsingSocketAppenders/socketclient.properties) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/socketclient.properties?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/socketclient.properties&p1=logging/log4j/branches/log4j12modules/examples/lf5/UsingSocketAppenders/socketclient.properties&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/socketclient.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/socketclient.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/socketserver.properties (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/UsingSocketAppenders/socketserver.properties) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/socketserver.properties?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/socketserver.properties&p1=logging/log4j/branches/log4j12modules/examples/lf5/UsingSocketAppenders/socketserver.properties&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/socketserver.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/UsingSocketAppenders/socketserver.properties ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Copied: logging/log4j/branches/log4j12modules/modules/lf5/examples/index.html (from r1345481, logging/log4j/branches/log4j12modules/examples/lf5/index.html) URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/examples/index.html?p2=logging/log4j/branches/log4j12modules/modules/lf5/examples/index.html&p1=logging/log4j/branches/log4j12modules/examples/lf5/index.html&r1=1345481&r2=1345492&rev=1345492&view=diff ============================================================================== (empty) Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/index.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: logging/log4j/branches/log4j12modules/modules/lf5/examples/index.html ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: logging/log4j/branches/log4j12modules/modules/lf5/pom.xml URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/pom.xml?rev=1345492&view=auto ============================================================================== --- logging/log4j/branches/log4j12modules/modules/lf5/pom.xml (added) +++ logging/log4j/branches/log4j12modules/modules/lf5/pom.xml Sat Jun 2 11:40:31 2012 @@ -0,0 +1,38 @@ + + + 4.0.0 + + org.apache.log4j + log4j-modules + 1.4.0-SNAPSHOT + + org.apache.log4j + log4j-lf5 + Apache Log4j-LF5 + jar + + + + org.apache.log4j + log4j-core + ${project.version} + + + + \ No newline at end of file Propchange: logging/log4j/branches/log4j12modules/modules/lf5/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/AppenderFinalizer.java URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/AppenderFinalizer.java?rev=1345492&view=auto ============================================================================== --- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/AppenderFinalizer.java (added) +++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/AppenderFinalizer.java Sat Jun 2 11:40:31 2012 @@ -0,0 +1,78 @@ +/* + * 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.lf5; + +import org.apache.log4j.lf5.viewer.LogBrokerMonitor; + +/** + * AppenderFinalizer has a single method that will finalize + * resources associated with a LogBrokerMonitor in the event + * that the LF5Appender class is destroyed, and the class loader + * is garbage collected. + * + * @author Brent Sprecher + */ + +// Contributed by ThoughtWorks Inc. + +public class AppenderFinalizer { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + protected LogBrokerMonitor _defaultMonitor = null; + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + + public AppenderFinalizer(LogBrokerMonitor defaultMonitor) { + _defaultMonitor = defaultMonitor; + } + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + /** + * @throws java.lang.Throwable + */ + protected void finalize() throws Throwable { + System.out.println("Disposing of the default LogBrokerMonitor instance"); + _defaultMonitor.dispose(); + } + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- + +} \ No newline at end of file Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/AppenderFinalizer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/DefaultLF5Configurator.java URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/DefaultLF5Configurator.java?rev=1345492&view=auto ============================================================================== --- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/DefaultLF5Configurator.java (added) +++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/DefaultLF5Configurator.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.lf5; + +import org.apache.log4j.PropertyConfigurator; +import org.apache.log4j.spi.Configurator; +import org.apache.log4j.spi.LoggerRepository; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +/** + * The DefaultLF5Configurator provides a default + * configuration for the LF5Appender. + * + * Note: The preferred method for configuring a LF5Appender + * is to use the LF5Manager class. This class ensures + * that configuration does not occur multiple times, and improves system + * performance. Reconfiguring the monitor multiple times can result in + * unexpected behavior. + * + * @author Brent Sprecher + */ + +// Contributed by ThoughtWorks Inc. + +public class DefaultLF5Configurator implements Configurator { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + /** + * This class should never be instantiated! It implements the + * Configurator + * interface, but does not provide the same functionality as full + * configurator class. + */ + private DefaultLF5Configurator() { + + } + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + /** + * This method configures the LF5Appender using a + * default configuration file. The default configuration file is + * defaultconfig.properties. + * @throws java.io.IOException + */ + public static void configure() throws IOException { + String resource = + "/org/apache/log4j/lf5/config/defaultconfig.properties"; + URL configFileResource = + DefaultLF5Configurator.class.getResource(resource); + + if (configFileResource != null) { + PropertyConfigurator.configure(configFileResource); + } else { + throw new IOException("Error: Unable to open the resource" + + resource); + } + + } + + public void doConfigure(InputStream inputStream, LoggerRepository repository) { + //To change body of implemented methods use File | Settings | File Templates. + } + + /** + * This is a dummy method that will throw an + * IllegalStateException if used. + */ + public void doConfigure(URL configURL, LoggerRepository repository) { + throw new IllegalStateException("This class should NOT be" + + " instantiated!"); + } + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- + +} \ No newline at end of file Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/DefaultLF5Configurator.java ------------------------------------------------------------------------------ svn:eol-style = native Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LF5Appender.java URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LF5Appender.java?rev=1345492&view=auto ============================================================================== --- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LF5Appender.java (added) +++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LF5Appender.java Sat Jun 2 11:40:31 2012 @@ -0,0 +1,266 @@ +/* + * 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.lf5; + +import java.awt.Toolkit; + +import org.apache.log4j.AppenderSkeleton; +import org.apache.log4j.lf5.viewer.LogBrokerMonitor; +import org.apache.log4j.spi.LocationInfo; +import org.apache.log4j.spi.LoggingEvent; + +/** + * LF5Appender logs events to a swing based logging + * console. The swing console supports turning categories on and off, + * multiple detail level views, as well as full text searching and many + * other capabilties. + * + * @author Brent Sprecher + */ + +// Contributed by ThoughtWorks Inc. + +public class LF5Appender extends AppenderSkeleton { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + protected LogBrokerMonitor _logMonitor; + protected static LogBrokerMonitor _defaultLogMonitor; + protected static AppenderFinalizer _finalizer; + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + + /** + * Constructs a LF5Appender using the default instance of + * the LogBrokerMonitor. This constructor should always + * be preferred over the + * LF5Appender(LogBrokerMonitor monitor) + * constructor, unless you need to spawn additional log monitoring + * windows. + */ + public LF5Appender() { + this(getDefaultInstance()); + } + + /** + * Constructs a LF5Appender using an instance of + * a LogBrokerMonitor supplied by the user. This + * constructor should only be used when you need to spawn + * additional log monitoring windows. + * + * @param monitor An instance of a LogBrokerMonitor + * created by the user. + */ + public LF5Appender(LogBrokerMonitor monitor) { + + if (monitor != null) { + _logMonitor = monitor; + } + } + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + + /** + * Appends a LoggingEvent record to the + * LF5Appender. + * @param event The LoggingEvent + * to be appended. + */ + public void append(LoggingEvent event) { + // Retrieve the information from the log4j LoggingEvent. + String category = event.getLoggerName(); + String logMessage = event.getRenderedMessage(); + String nestedDiagnosticContext = event.getNDC(); + String threadDescription = event.getThreadName(); + String level = event.getLevel().toString(); + long time = event.timeStamp; + LocationInfo locationInfo = event.getLocationInformation(); + + // Add the logging event information to a LogRecord + Log4JLogRecord record = new Log4JLogRecord(); + + record.setCategory(category); + record.setMessage(logMessage); + record.setLocation(locationInfo.fullInfo); + record.setMillis(time); + record.setThreadDescription(threadDescription); + + if (nestedDiagnosticContext != null) { + record.setNDC(nestedDiagnosticContext); + } else { + record.setNDC(""); + } + + if (event.getThrowableInformation() != null) { + record.setThrownStackTrace(event.getThrowableInformation()); + } + + try { + record.setLevel(LogLevel.valueOf(level)); + } catch (LogLevelFormatException e) { + // If the priority level doesn't match one of the predefined + // log levels, then set the level to warning. + record.setLevel(LogLevel.WARN); + } + + if (_logMonitor != null) { + _logMonitor.addMessage(record); + } + } + + /** + * This method is an empty implementation of the close() method inherited + * from the org.apache.log4j.Appender interface. + */ + public void close() { + } + + /** + * Returns a value that indicates whether this appender requires a + * Layout. This method always returns false. + * No layout is required for the LF5Appender. + */ + public boolean requiresLayout() { + return false; + } + + /** + * This method is used to set the property that controls whether + * the LogBrokerMonitor is hidden or closed when a user + * exits + * the monitor. By default, the LogBrokerMonitor will hide + * itself when the log window is exited, and the swing thread will + * continue to run in the background. If this property is + * set to true, the LogBrokerMonitor will call System.exit(0) + * and will shut down swing thread and the virtual machine. + * + * @param callSystemExitOnClose A boolean value indicating whether + * to call System.exit(0) when closing the log window. + */ + public void setCallSystemExitOnClose(boolean callSystemExitOnClose) { + _logMonitor.setCallSystemExitOnClose(callSystemExitOnClose); + } + + /** + * The equals method compares two LF5Appenders and determines whether + * they are equal. Two Appenders will be considered equal + * if, and only if, they both contain references to the same + * LogBrokerMonitor. + * + * @param compareTo A boolean value indicating whether + * the two LF5Appenders are equal. + */ + public boolean equals(LF5Appender compareTo) { + // If both reference the same LogBrokerMonitor, they are equal. + return _logMonitor == compareTo.getLogBrokerMonitor(); + } + + public LogBrokerMonitor getLogBrokerMonitor() { + return _logMonitor; + } + + public static void main(String[] args) { + new LF5Appender(); + } + + public void setMaxNumberOfRecords(int maxNumberOfRecords) { + _defaultLogMonitor.setMaxNumberOfLogRecords(maxNumberOfRecords); + } + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + /** + * @return The default instance of the LogBrokerMonitor. + */ + protected static synchronized LogBrokerMonitor getDefaultInstance() { + if (_defaultLogMonitor == null) { + try { + _defaultLogMonitor = + new LogBrokerMonitor(LogLevel.getLog4JLevels()); + _finalizer = new AppenderFinalizer(_defaultLogMonitor); + + _defaultLogMonitor.setFrameSize(getDefaultMonitorWidth(), + getDefaultMonitorHeight()); + _defaultLogMonitor.setFontSize(12); + _defaultLogMonitor.show(); + + } catch (SecurityException e) { + _defaultLogMonitor = null; + } + } + + return _defaultLogMonitor; + } + + /** + * @return the screen width from Toolkit.getScreenSize() + * if possible, otherwise returns 800 + * @see java.awt.Toolkit + */ + protected static int getScreenWidth() { + try { + return Toolkit.getDefaultToolkit().getScreenSize().width; + } catch (Throwable t) { + return 800; + } + } + + /** + * @return the screen height from Toolkit.getScreenSize() + * if possible, otherwise returns 600 + * @see java.awt.Toolkit + */ + protected static int getScreenHeight() { + try { + return Toolkit.getDefaultToolkit().getScreenSize().height; + } catch (Throwable t) { + return 600; + } + } + + protected static int getDefaultMonitorWidth() { + return (3 * getScreenWidth()) / 4; + } + + protected static int getDefaultMonitorHeight() { + return (3 * getScreenHeight()) / 4; + } + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- + +} Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LF5Appender.java ------------------------------------------------------------------------------ svn:eol-style = native Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/Log4JLogRecord.java URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/Log4JLogRecord.java?rev=1345492&view=auto ============================================================================== --- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/Log4JLogRecord.java (added) +++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/Log4JLogRecord.java Sat Jun 2 11:40:31 2012 @@ -0,0 +1,116 @@ +/* + * 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.lf5; + +import org.apache.log4j.spi.ThrowableInformation; + +/** + * A Log4JLogRecord encapsulates + * the details of your log4j LoggingEvent in a format usable + * by the LogBrokerMonitor. + * + * @author Brent Sprecher + */ + +// Contributed by ThoughtWorks Inc. + +public class Log4JLogRecord extends LogRecord { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + + /** + * Constructs an instance of a Log4JLogRecord. + */ + public Log4JLogRecord() { + } + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + /** + * Determines which Priority levels will + * be displayed in colored font when the LogMonitorAppender + * renders this log message. By default, messages will be colored + * red if they are of Priority ERROR or FATAL. + * + * @return true if the log level is ERROR or FATAL. + */ + public boolean isSevereLevel() { + boolean isSevere = false; + + if (LogLevel.ERROR.equals(getLevel()) || + LogLevel.FATAL.equals(getLevel())) { + isSevere = true; + } + + return isSevere; + } + + /** + * Set stack trace information associated with this Log4JLogRecord. + * When this method is called, the stack trace in a + * String-based format is made + * available via the getThrownStackTrace() method. + * + * @param throwableInfo An org.apache.log4j.spi.ThrowableInformation to + * associate with this Log4JLogRecord. + * @see #getThrownStackTrace() + */ + public void setThrownStackTrace(ThrowableInformation throwableInfo) { + String[] stackTraceArray = throwableInfo.getThrowableStrRep(); + + StringBuffer stackTrace = new StringBuffer(); + String nextLine; + + for (int i = 0; i < stackTraceArray.length; i++) { + nextLine = stackTraceArray[i] + "\n"; + stackTrace.append(nextLine); + } + + _thrownStackTrace = stackTrace.toString(); + } + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- + +} + + + Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/Log4JLogRecord.java ------------------------------------------------------------------------------ svn:eol-style = native Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogLevel.java URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogLevel.java?rev=1345492&view=auto ============================================================================== --- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogLevel.java (added) +++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogLevel.java Sat Jun 2 11:40:31 2012 @@ -0,0 +1,278 @@ +/* + * 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.lf5; + +import java.awt.Color; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * The LogLevel class defines a set of standard logging levels. + * + * The logging Level objects are ordered and are specified by ordered + * integers. Enabling logging at a given level also enables logging at all + * higher levels. + * + * @author Michael J. Sikorsky + * @author Robert Shaw + * @author Brent Sprecher + * @author Richard Hurst + * @author Brad Marlborough + */ + +// Contributed by ThoughtWorks Inc. + +public class LogLevel implements java.io.Serializable { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + // log4j log levels. + public final static LogLevel FATAL = new LogLevel("FATAL", 0); + public final static LogLevel ERROR = new LogLevel("ERROR", 1); + public final static LogLevel WARN = new LogLevel("WARN", 2); + public final static LogLevel INFO = new LogLevel("INFO", 3); + public final static LogLevel DEBUG = new LogLevel("DEBUG", 4); + + // jdk1.4 log levels NOTE: also includes INFO + public final static LogLevel SEVERE = new LogLevel("SEVERE", 1); + public final static LogLevel WARNING = new LogLevel("WARNING", 2); + public final static LogLevel CONFIG = new LogLevel("CONFIG", 4); + public final static LogLevel FINE = new LogLevel("FINE", 5); + public final static LogLevel FINER = new LogLevel("FINER", 6); + public final static LogLevel FINEST = new LogLevel("FINEST", 7); + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + protected String _label; + protected int _precedence; + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + private static LogLevel[] _log4JLevels; + private static LogLevel[] _jdk14Levels; + private static LogLevel[] _allDefaultLevels; + private static Map _logLevelMap; + private static Map _logLevelColorMap; + private static Map _registeredLogLevelMap = new HashMap(); + + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + static { + _log4JLevels = new LogLevel[]{FATAL, ERROR, WARN, INFO, DEBUG}; + _jdk14Levels = new LogLevel[]{SEVERE, WARNING, INFO, + CONFIG, FINE, FINER, FINEST}; + _allDefaultLevels = new LogLevel[]{FATAL, ERROR, WARN, INFO, DEBUG, + SEVERE, WARNING, CONFIG, FINE, FINER, FINEST}; + + _logLevelMap = new HashMap(); + for (int i = 0; i < _allDefaultLevels.length; i++) { + _logLevelMap.put(_allDefaultLevels[i].getLabel(), _allDefaultLevels[i]); + } + + // prepopulate map with levels and text color of black + _logLevelColorMap = new HashMap(); + for (int i = 0; i < _allDefaultLevels.length; i++) { + _logLevelColorMap.put(_allDefaultLevels[i], Color.black); + } + } + + public LogLevel(String label, int precedence) { + _label = label; + _precedence = precedence; + } + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + + /** + * Return the Label of the LogLevel. + */ + public String getLabel() { + return _label; + } + + /** + * Returns true if the level supplied is encompassed by this level. + * For example, LogLevel.SEVERE encompasses no other LogLevels and + * LogLevel.FINE encompasses all other LogLevels. By definition, + * a LogLevel encompasses itself. + */ + public boolean encompasses(LogLevel level) { + if (level.getPrecedence() <= getPrecedence()) { + return true; + } + + return false; + } + + /** + * Convert a log level label into a LogLevel object. + * + * @param level The label of a level to be converted into a LogLevel. + * @return LogLevel The LogLevel with a label equal to level. + * @throws LogLevelFormatException Is thrown when the level can not be + * converted into a LogLevel. + */ + public static LogLevel valueOf(String level) + throws LogLevelFormatException { + LogLevel logLevel = null; + if (level != null) { + level = level.trim().toUpperCase(); + logLevel = (LogLevel) _logLevelMap.get(level); + } + + // Didn't match, Check for registered LogLevels + if (logLevel == null && _registeredLogLevelMap.size() > 0) { + logLevel = (LogLevel) _registeredLogLevelMap.get(level); + } + + if (logLevel == null) { + StringBuffer buf = new StringBuffer(); + buf.append("Error while trying to parse (" + level + ") into"); + buf.append(" a LogLevel."); + throw new LogLevelFormatException(buf.toString()); + } + return logLevel; + } + + /** + * Registers a used defined LogLevel. + * + * @param logLevel The log level to be registered. Cannot be a default LogLevel + * @return LogLevel The replaced log level. + */ + public static LogLevel register(LogLevel logLevel) { + if (logLevel == null) return null; + + // ensure that this is not a default log level + if (_logLevelMap.get(logLevel.getLabel()) == null) { + return (LogLevel) _registeredLogLevelMap.put(logLevel.getLabel(), logLevel); + } + + return null; + } + + public static void register(LogLevel[] logLevels) { + if (logLevels != null) { + for (int i = 0; i < logLevels.length; i++) { + register(logLevels[i]); + } + } + } + + public static void register(List logLevels) { + if (logLevels != null) { + Iterator it = logLevels.iterator(); + while (it.hasNext()) { + register((LogLevel) it.next()); + } + } + } + + public boolean equals(Object o) { + boolean equals = false; + + if (o instanceof LogLevel) { + if (this.getPrecedence() == + ((LogLevel) o).getPrecedence()) { + equals = true; + } + + } + + return equals; + } + + public int hashCode() { + return _label.hashCode(); + } + + public String toString() { + return _label; + } + + // set a text color for a specific log level + public void setLogLevelColorMap(LogLevel level, Color color) { + // remove the old entry + _logLevelColorMap.remove(level); + // add the new color entry + if (color == null) { + color = Color.black; + } + _logLevelColorMap.put(level, color); + } + + public static void resetLogLevelColorMap() { + // empty the map + _logLevelColorMap.clear(); + + // repopulate map and reset text color black + for (int i = 0; i < _allDefaultLevels.length; i++) { + _logLevelColorMap.put(_allDefaultLevels[i], Color.black); + } + } + + /** + * @return A List of LogLevel objects that map + * to log4j Priority objects. + */ + public static List getLog4JLevels() { + return Arrays.asList(_log4JLevels); + } + + public static List getJdk14Levels() { + return Arrays.asList(_jdk14Levels); + } + + public static List getAllDefaultLevels() { + return Arrays.asList(_allDefaultLevels); + } + + public static Map getLogLevelColorMap() { + return _logLevelColorMap; + } + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + protected int getPrecedence() { + return _precedence; + } + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- + +} + + + + + + Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogLevel.java ------------------------------------------------------------------------------ svn:eol-style = native Added: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogLevelFormatException.java URL: http://svn.apache.org/viewvc/logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogLevelFormatException.java?rev=1345492&view=auto ============================================================================== --- logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogLevelFormatException.java (added) +++ logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogLevelFormatException.java Sat Jun 2 11:40:31 2012 @@ -0,0 +1,73 @@ +/* + * 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.lf5; + +/** + * Thrown to indicate that the client has attempted to convert a string + * to one the LogLevel types, but the string does not have the appropriate + * format. + * + * @author Michael J. Sikorsky< + * @author Robert Shaw + */ + +// Contributed by ThoughtWorks Inc. + +public class LogLevelFormatException extends Exception { + //-------------------------------------------------------------------------- + // Constants: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Variables: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Constructors: + //-------------------------------------------------------------------------- + + public LogLevelFormatException(String message) { + super(message); + } + + //-------------------------------------------------------------------------- + // Public Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Protected Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Private Methods: + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // Nested Top-Level Classes or Interfaces: + //-------------------------------------------------------------------------- + +} + + + + + + Propchange: logging/log4j/branches/log4j12modules/modules/lf5/src/main/java/org/apache/log4j/lf5/LogLevelFormatException.java ------------------------------------------------------------------------------ svn:eol-style = native