[jboss-cvs] JBossAS SVN: r57333 - projects/test/trunk/test/src/main/org/jboss/test/logging

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Oct 1 19:28:49 EDT 2006


Author: scott.stark at jboss.org
Date: 2006-10-01 19:28:47 -0400 (Sun, 01 Oct 2006)
New Revision: 57333

Added:
   projects/test/trunk/test/src/main/org/jboss/test/logging/Log4jConsoleLoggingPlugin.java
Modified:
   projects/test/trunk/test/src/main/org/jboss/test/logging/LoggingPlugin.java
Log:
Include a Log4jConsoleLoggingPlugin org.jboss.test.logging.LoggingPlugin implementation that simply configures a console appender to avoid conflicting log4j configurations.

Added: projects/test/trunk/test/src/main/org/jboss/test/logging/Log4jConsoleLoggingPlugin.java
===================================================================
--- projects/test/trunk/test/src/main/org/jboss/test/logging/Log4jConsoleLoggingPlugin.java	2006-10-01 23:12:38 UTC (rev 57332)
+++ projects/test/trunk/test/src/main/org/jboss/test/logging/Log4jConsoleLoggingPlugin.java	2006-10-01 23:28:47 UTC (rev 57333)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.logging;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+
+/**
+ * A LoggingPlugin that configures a console log4j appender without looking
+ * for any configuration resources.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class Log4jConsoleLoggingPlugin extends LoggingPlugin
+{
+   public void enableTrace(String name)
+   {
+      Logger.getLogger(name).setLevel(XLevel.TRACE);
+   }
+
+   public void setUp() throws Exception
+   {
+      // Setup a console appender
+      BasicConfigurator.resetConfiguration();
+      PatternLayout layout = new PatternLayout("%r %-5p [%c{1}] %m%n");
+      ConsoleAppender appender = new ConsoleAppender(layout);
+      BasicConfigurator.configure(appender);
+   }
+
+}

Modified: projects/test/trunk/test/src/main/org/jboss/test/logging/LoggingPlugin.java
===================================================================
--- projects/test/trunk/test/src/main/org/jboss/test/logging/LoggingPlugin.java	2006-10-01 23:12:38 UTC (rev 57332)
+++ projects/test/trunk/test/src/main/org/jboss/test/logging/LoggingPlugin.java	2006-10-01 23:28:47 UTC (rev 57333)
@@ -30,7 +30,12 @@
 public abstract class LoggingPlugin
 {
    /**
-    * Get the logging plugin
+    * Get the logging plugin. This looks at the system property org.jboss.test.logging.LogginPlugin,
+    * and if this is not defined, org.jboss.test.logging.Log4jLoggingPlugin is used. Another
+    * useful default is org.jboss.test.logging.Log4jConsoleLoggingPlugin, a plugin that
+    * simply configures a console appender.
+    * @see org.jboss.test.logging.Log4jLoggingPlugin
+    * @see org.jboss.test.logging.Log4jConsoleLoggingPlugin
     * 
     * @return the logging plugin
     * @throws Exception for any error




More information about the jboss-cvs-commits mailing list