geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: rev 57150 - in geronimo/trunk/modules: assembly/src/plan assembly/src/var/log kernel/src/java/org/apache/geronimo/kernel kernel/src/java/org/apache/geronimo/kernel/log system/src/java/org/apache/geronimo/system/logging/log4j system/src/java/org/apache/geronimo/system/logging/log4j/appender system/src/java/org/apache/geronimo/system/serverinfo
Date Wed, 10 Nov 2004 08:15:54 GMT
Author: dain
Date: Wed Nov 10 00:15:53 2004
New Revision: 57150

Added:
   geronimo/trunk/modules/assembly/src/var/log/
   geronimo/trunk/modules/assembly/src/var/log/client-log4j.properties
   geronimo/trunk/modules/assembly/src/var/log/deployer-log4j.properties
   geronimo/trunk/modules/assembly/src/var/log/server-log4j.properties
Removed:
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/logging/log4j/appender/AbstractAppenderService.java
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/logging/log4j/appender/ConsoleAppenderService.java
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/logging/log4j/appender/DailyRollingFileAppenderService.java
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/logging/log4j/appender/FileAppenderService.java
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/logging/log4j/appender/RollingFileAppenderService.java
Modified:
   geronimo/trunk/modules/assembly/src/plan/client-system-plan.xml
   geronimo/trunk/modules/assembly/src/plan/deployer-system-plan.xml
   geronimo/trunk/modules/assembly/src/plan/system-plan.xml
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelMBean.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/log/GeronimoLogFactory.java
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/logging/log4j/Log4jService.java
   geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java
Log:
Removed gbeans that wrapped log4j appenders as they don't work reliable
Added -log4j.properties files for server, client and deployer


Modified: geronimo/trunk/modules/assembly/src/plan/client-system-plan.xml
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/client-system-plan.xml	(original)
+++ geronimo/trunk/modules/assembly/src/plan/client-system-plan.xml	Wed Nov 10 00:15:53 2004
@@ -52,27 +52,8 @@
 
     <!-- Logging service -->
     <gbean name="geronimo.client:role=Logger" class="org.apache.geronimo.system.logging.log4j.Log4jService">
-        <attribute name="rootLoggerLevel" type="java.lang.String">DEBUG</attribute>
-        <attribute name="refreshPeriod" type="int">60</attribute>
-        <attribute name="configurationFile" type="java.lang.String">var/log/log4j.xml</attribute>
-        <reference name="ServerInfo">geronimo.client:role=ServerInfo</reference>
-    </gbean>
-
-    <gbean name="geronimo.client:role=LogAppender,type=ConsoleAppender" class="org.apache.geronimo.system.logging.log4j.appender.ConsoleAppenderService">
-        <attribute name="threshold" type="java.lang.String">INFO</attribute>
-        <attribute name="layoutPattern" type="java.lang.String">%d{ABSOLUTE} %-5p [%c{1}]
%m%n</attribute>
-        <attribute name="target" type="java.lang.String">System.out</attribute>
-    </gbean>
-
-    <gbean name="geronimo.client:role=LogAppender,type=DailyRollingFileAppender" class="org.apache.geronimo.system.logging.log4j.appender.RollingFileAppenderService">
-        <attribute name="threshold" type="java.lang.String">DEBUG</attribute>
-        <attribute name="layoutPattern" type="java.lang.String">%d{ABSOLUTE} %-5p [%c{1}]
%m%n</attribute>
-        <attribute name="append" type="boolean">true</attribute>
-        <attribute name="file" type="java.lang.String">var/log/client.log</attribute>
-        <attribute name="bufferedIO" type="boolean">false</attribute>
-        <attribute name="bufferedSize" type="int">8192</attribute>
-        <attribute name="maxBackupIndex" type="int">1</attribute>
-        <attribute name="maxFileSize" type="java.lang.String">10MB</attribute>
+        <attribute name="configurationFile">var/log/client-log4j.properties</attribute>
+        <attribute name="refreshPeriod">60</attribute>
         <reference name="ServerInfo">geronimo.client:role=ServerInfo</reference>
     </gbean>
 

Modified: geronimo/trunk/modules/assembly/src/plan/deployer-system-plan.xml
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/deployer-system-plan.xml	(original)
+++ geronimo/trunk/modules/assembly/src/plan/deployer-system-plan.xml	Wed Nov 10 00:15:53
2004
@@ -46,27 +46,8 @@
 
     <!-- Logging service -->
     <gbean name="geronimo.deployment:role=Logger" class="org.apache.geronimo.system.logging.log4j.Log4jService">
-        <attribute name="rootLoggerLevel" type="java.lang.String">DEBUG</attribute>
-        <attribute name="refreshPeriod" type="int">60</attribute>
-        <attribute name="configurationFile" type="java.lang.String">var/log/log4j.xml</attribute>
+        <attribute name="configurationFile">var/log/deployer-log4j.properties</attribute>
+        <attribute name="refreshPeriod">60</attribute>
         <reference name="ServerInfo">geronimo.system:role=ServerInfo</reference>
-    </gbean>
-
-    <gbean name="geronimo.deployments:role=LogAppender,type=ConsoleAppender" class="org.apache.geronimo.system.logging.log4j.appender.ConsoleAppenderService">
-        <attribute name="threshold" type="java.lang.String">ERROR</attribute>
-        <attribute name="layoutPattern" type="java.lang.String">%d{ABSOLUTE} %-5p [%c{1}]
%m%n</attribute>
-        <attribute name="target" type="java.lang.String">System.out</attribute>
-    </gbean>
-
-    <gbean name="geronimo.deployment:role=LogAppender,type=DailyRollingFileAppender" class="org.apache.geronimo.system.logging.log4j.appender.RollingFileAppenderService">
-        <attribute name="threshold" type="java.lang.String">DEBUG</attribute>
-        <attribute name="layoutPattern" type="java.lang.String">%d{ABSOLUTE} %-5p [%c{1}]
%m%n</attribute>
-        <attribute name="append" type="boolean">true</attribute>
-        <attribute name="file" type="java.lang.String">var/log/deployer.log</attribute>
-        <attribute name="bufferedIO" type="boolean">false</attribute>
-        <attribute name="bufferedSize" type="int">8192</attribute>
-        <attribute name="maxBackupIndex" type="int">1</attribute>
-        <attribute name="maxFileSize" type="java.lang.String">10MB</attribute>
-        <reference name="ServerInfo">geronimo.deployment:role=ServerInfo</reference>
     </gbean>
 </configuration>

Modified: geronimo/trunk/modules/assembly/src/plan/system-plan.xml
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/system-plan.xml	(original)
+++ geronimo/trunk/modules/assembly/src/plan/system-plan.xml	Wed Nov 10 00:15:53 2004
@@ -58,27 +58,8 @@
 
     <!-- Logging service -->
     <gbean name="geronimo.system:role=Logger" class="org.apache.geronimo.system.logging.log4j.Log4jService">
-        <attribute name="rootLoggerLevel" type="java.lang.String">DEBUG</attribute>
-        <attribute name="refreshPeriod" type="int">60</attribute>
-        <attribute name="configurationFile" type="java.lang.String">var/log/log4j.xml</attribute>
-        <reference name="ServerInfo">geronimo.system:role=ServerInfo</reference>
-    </gbean>
-
-    <gbean name="geronimo.system:role=LogAppender,type=ConsoleAppender" class="org.apache.geronimo.system.logging.log4j.appender.ConsoleAppenderService">
-        <attribute name="threshold" type="java.lang.String">INFO</attribute>
-        <attribute name="layoutPattern" type="java.lang.String">%d{ABSOLUTE} %-5p [%c{1}]
%m%n</attribute>
-        <attribute name="target" type="java.lang.String">System.out</attribute>
-    </gbean>
-
-    <gbean name="geronimo.system:role=LogAppender,type=DailyRollingFileAppender" class="org.apache.geronimo.system.logging.log4j.appender.RollingFileAppenderService">
-        <attribute name="threshold" type="java.lang.String">DEBUG</attribute>
-        <attribute name="layoutPattern" type="java.lang.String">%d{ABSOLUTE} %-5p [%c{1}]
%m%n</attribute>
-        <attribute name="append" type="boolean">true</attribute>
-        <attribute name="file" type="java.lang.String">var/log/geronimo.log</attribute>
-        <attribute name="bufferedIO" type="boolean">false</attribute>
-        <attribute name="bufferedSize" type="int">8192</attribute>
-        <attribute name="maxBackupIndex" type="int">1</attribute>
-        <attribute name="maxFileSize" type="java.lang.String">10MB</attribute>
+        <attribute name="configurationFile">var/log/server-log4j.properties</attribute>
+        <attribute name="refreshPeriod">60</attribute>
         <reference name="ServerInfo">geronimo.system:role=ServerInfo</reference>
     </gbean>
 
@@ -93,5 +74,4 @@
         <attribute name="namingFactoryUrlPkgs" type="java.lang.String">org.apache.geronimo.naming</attribute>
         <attribute name="namingProviderUrl" type="java.lang.String">rmi://localhost:1099</attribute>
     </gbean>
-    
 </configuration>

Added: geronimo/trunk/modules/assembly/src/var/log/client-log4j.properties
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/assembly/src/var/log/client-log4j.properties	Wed Nov 10 00:15:53
2004
@@ -0,0 +1,45 @@
+##
+## Copyright 2004 The Apache Software Foundation
+##
+## Licensed 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.
+##
+## $Rev: 55226 $ $Date: 2004-10-21 08:26:49 -0700 (Thu, 21 Oct 2004) $
+##
+
+log4j.rootCategory=DEBUG, CONSOLE, FILE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=INFO
+log4j.appender.CONSOLE.Target=System.out
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
+
+log4j.appender.FILE=org.apache.log4j.RollingFileAppender
+log4j.appender.FILE.threshold=DEBUG
+log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
+log4j.appender.FILE.append=true
+log4j.appender.FILE.file=${geronimo.base.dir}/var/log/client.log
+log4j.appender.FILE.bufferedIO=false
+log4j.appender.FILE.maxBackupIndex=3
+log4j.appender.FILE.maxFileSize=10MB
+
+#
+# Example: enable trace logging from CONSOLE appender
+#
+#log4j.appender.CONSOLE.Threshold=TRACE#org.apache.geronimo.system.logging.log4j.XLevel
+
+#
+# Example: enable trace messages from foo.bar category
+#
+#log4j.category.foo.bar=TRACE#org.apache.geronimo.system.logging.log4j.XLevel

Added: geronimo/trunk/modules/assembly/src/var/log/deployer-log4j.properties
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/assembly/src/var/log/deployer-log4j.properties	Wed Nov 10 00:15:53
2004
@@ -0,0 +1,45 @@
+##
+## Copyright 2004 The Apache Software Foundation
+##
+## Licensed 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.
+##
+## $Rev: 55226 $ $Date: 2004-10-21 08:26:49 -0700 (Thu, 21 Oct 2004) $
+##
+
+log4j.rootCategory=DEBUG, CONSOLE, FILE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=INFO
+log4j.appender.CONSOLE.Target=System.out
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
+
+log4j.appender.FILE=org.apache.log4j.RollingFileAppender
+log4j.appender.FILE.threshold=DEBUG
+log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
+log4j.appender.FILE.append=true
+log4j.appender.FILE.file=${geronimo.base.dir}/var/log/deployer.log
+log4j.appender.FILE.bufferedIO=false
+log4j.appender.FILE.maxBackupIndex=3
+log4j.appender.FILE.maxFileSize=10MB
+
+#
+# Example: enable trace logging from CONSOLE appender
+#
+#log4j.appender.CONSOLE.Threshold=TRACE#org.apache.geronimo.system.logging.log4j.XLevel
+
+#
+# Example: enable trace messages from foo.bar category
+#
+#log4j.category.foo.bar=TRACE#org.apache.geronimo.system.logging.log4j.XLevel

Added: geronimo/trunk/modules/assembly/src/var/log/server-log4j.properties
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/assembly/src/var/log/server-log4j.properties	Wed Nov 10 00:15:53
2004
@@ -0,0 +1,45 @@
+##
+## Copyright 2004 The Apache Software Foundation
+##
+## Licensed 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.
+##
+## $Rev: 55226 $ $Date: 2004-10-21 08:26:49 -0700 (Thu, 21 Oct 2004) $
+##
+
+log4j.rootCategory=DEBUG, CONSOLE, FILE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=INFO
+log4j.appender.CONSOLE.Target=System.out
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
+
+log4j.appender.FILE=org.apache.log4j.RollingFileAppender
+log4j.appender.FILE.threshold=DEBUG
+log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
+log4j.appender.FILE.append=true
+log4j.appender.FILE.file=${geronimo.base.dir}/var/log/geronimo.log
+log4j.appender.FILE.bufferedIO=false
+log4j.appender.FILE.maxBackupIndex=3
+log4j.appender.FILE.maxFileSize=10MB
+
+#
+# Example: enable trace logging from CONSOLE appender
+#
+#log4j.appender.CONSOLE.Threshold=TRACE#org.apache.geronimo.system.logging.log4j.XLevel
+
+#
+# Example: enable trace messages from foo.bar category
+#
+#log4j.category.foo.bar=TRACE#org.apache.geronimo.system.logging.log4j.XLevel

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java	Wed Nov
10 00:15:53 2004
@@ -579,6 +579,10 @@
         return running;
     }
 
+    public ClassLoader getClassLoaderFor(ObjectName objectName) throws InstanceNotFoundException
{
+        return mbServer.getClassLoaderFor(objectName);
+    }
+
     private static void processQueue() {
         KernelReference kernelRef;
         while ((kernelRef = (KernelReference) queue.poll()) != null) {

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelMBean.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelMBean.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/KernelMBean.java	Wed
Nov 10 00:15:53 2004
@@ -156,4 +156,6 @@
     void unregisterShutdownHook(Runnable hook);
 
     void shutdown();
+
+    ClassLoader getClassLoaderFor(ObjectName objectName) throws InstanceNotFoundException;
 }

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/log/GeronimoLogFactory.java
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/log/GeronimoLogFactory.java
(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/log/GeronimoLogFactory.java
Wed Nov 10 00:15:53 2004
@@ -48,7 +48,7 @@
 
     public void setLogFactory(LogFactory logFactory) {
         // change the log factory
-        this.logFactory = logFactory;
+        GeronimoLogFactory.logFactory = logFactory;
 
         // update all known logs to use instances of the new factory
         Set logs = getInstances();

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/logging/log4j/Log4jService.java
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/logging/log4j/Log4jService.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/logging/log4j/Log4jService.java
Wed Nov 10 00:15:53 2004
@@ -17,11 +17,18 @@
 
 package org.apache.geronimo.system.logging.log4j;
 
-import java.net.URI;
-import java.net.URL;
-import java.net.URLConnection;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.net.MalformedURLException;
 import java.util.Timer;
 import java.util.TimerTask;
+import java.util.Set;
+import java.util.Iterator;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogConfigurationException;
@@ -32,6 +39,7 @@
 import org.apache.geronimo.kernel.log.GeronimoLogFactory;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
 
 /**
@@ -53,7 +61,7 @@
     /**
      * The properties service
      */
-    private ServerInfo serverInfo;
+    private final ServerInfo serverInfo;
 
     /**
      * The URL watch timer (in daemon mode).
@@ -71,11 +79,6 @@
     private long lastChanged = -1;
 
     /**
-     * The level used for the root logger
-     */
-    private Level rootLoggerLevel;
-
-    /**
      * Is this service running?
      */
     private boolean running = false;
@@ -86,12 +89,7 @@
      * @param configurationFile The log4j configuration file.
      * @param refreshPeroid The refresh refreshPeroid (in seconds).
      */
-    public Log4jService(final String rootLoggerLevel, final String configurationFile, final
int refreshPeroid, ServerInfo serverInfo) {
-        LogFactory logFactory = LogFactory.getFactory();
-        if (!(logFactory instanceof GeronimoLogFactory)) {
-            throw new IllegalStateException("Commons log factory: " + logFactory + " is not
a GeronimoLogFactory");
-        }
-        this.rootLoggerLevel = XLevel.toLevel(rootLoggerLevel);
+    public Log4jService(final String configurationFile, final int refreshPeroid, ServerInfo
serverInfo) {
         this.refreshPeriod = refreshPeroid;
         this.configurationFile = configurationFile;
         this.serverInfo = serverInfo;
@@ -101,8 +99,10 @@
      * Gets the level of the root logger.
      */
     public synchronized String getRootLoggerLevel() {
-        if (rootLoggerLevel != null) {
-            return rootLoggerLevel.toString();
+        Level level = LogManager.getRootLogger().getLevel();
+
+        if (level != null) {
+            return level.toString();
         }
 
         return null;
@@ -114,14 +114,26 @@
      * @param level The level to change the logger to.
      */
     public synchronized void setRootLoggerLevel(final String level) {
-        if (level == null) {
-            rootLoggerLevel = null;
-        } else {
-            rootLoggerLevel = XLevel.toLevel(level);
-            if (running) {
-                Logger.getRootLogger().setLevel(rootLoggerLevel);
-            }
+        LogManager.getRootLogger().setLevel(XLevel.toLevel(level));
+    }
+
+    /**
+     * Gets the level of the logger of the give name.
+     *
+     * @param logger The logger to inspect.
+     */
+    public String getLoggerEffectiveLevel(final String logger) {
+        if (logger == null) {
+            throw new IllegalArgumentException("logger is null");
+        }
+
+        Level level = LogManager.getLogger(logger).getEffectiveLevel();
+
+        if (level != null) {
+            return level.toString();
         }
+
+        return null;
     }
 
     /**
@@ -134,7 +146,7 @@
             throw new IllegalArgumentException("logger is null");
         }
 
-        Level level = Logger.getLogger(logger).getLevel();
+        Level level = LogManager.getLogger(logger).getLevel();
 
         if (level != null) {
             return level.toString();
@@ -209,14 +221,102 @@
     }
 
     /**
+     * Get the content of logging configuration file.
+     *
+     * @return the content of logging configuration file
+     */
+    public synchronized String getConfiguration() {
+        File file = resolveConfigurationFile();
+        if (file == null || !file.canRead()) {
+            return null;
+        }
+        Reader in = null;
+        try {
+            StringBuffer configuration = new StringBuffer();
+            in = new InputStreamReader(new FileInputStream(file));
+            char[] buffer = new char[4096];
+            for (int size = in.read(buffer); size >= 0; size = in.read(buffer)) {
+                configuration.append(buffer, 0, size);
+            }
+            return configuration.toString();
+        } catch (IOException e) {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e1) {
+                    e1.printStackTrace();
+                }
+            }
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * Overwrites the content of logging configuration file.
+     *
+     * @param configuration the new content of logging configuration file
+     */
+    public synchronized void setConfiguration(final String configuration) throws IOException
{
+        if (configuration == null || configuration.length() == 0) {
+            throw new IllegalArgumentException("configuration is null or an empty string");
+        }
+
+        File file = resolveConfigurationFile();
+        if (file == null) {
+            throw new IllegalStateException("Configuration file is null");
+        }
+
+        // make parent directory if necessary
+        if (!file.getParentFile().exists()) {
+            if (!file.getParentFile().mkdirs()) {
+                throw new IllegalStateException("Could not create parent directory of log
configuration file: " + file.getParent());
+            }
+        }
+
+        // verify that the file is writable or does not exist
+        if (file.exists() && !file.canWrite()) {
+            throw new IllegalStateException("Configuration file is not writable: " + file.getAbsolutePath());
+        }
+
+        OutputStream out = null;
+        try {
+            out = new FileOutputStream(file);
+            out.write(configuration.getBytes());
+        } finally {
+            if (out != null) {
+                try {
+                    out.close();
+                } catch (IOException e) {
+                    e.printStackTrace();  //To change body of catch statement use File |
Settings | File Templates.
+                }
+            }
+        }
+    }
+
+    /**
      * Force the logging system to reconfigure.
      */
     public void reconfigure() {
-        URL url = resolveURL();
-        if (url == null) {
+        File file = resolveConfigurationFile();
+        if (file == null) {
             return;
         }
-        URLConfigurator.configure(url);
+        try {
+            URLConfigurator.configure(file.toURL());
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        }
+
+        // refresh the level info for every log
+        GeronimoLogFactory logFactory = (GeronimoLogFactory) LogFactory.getFactory();
+        Set instances = logFactory.getInstances();
+        for (Iterator iterator = instances.iterator(); iterator.hasNext();) {
+            Object log = iterator.next();
+            if (log instanceof CachingLog4jLog) {
+                ((CachingLog4jLog)log).updateLevelInfo();
+            }
+        }
     }
 
     private synchronized void schedule() {
@@ -235,26 +335,28 @@
     }
 
     public void doStart() {
+        LogFactory logFactory = LogFactory.getFactory();
+        if (!(logFactory instanceof GeronimoLogFactory)) {
+            throw new IllegalStateException("Commons log factory: " + logFactory + " is not
a GeronimoLogFactory");
+        }
+
         synchronized (this) {
+            timer = new Timer(true);
+
             // Peroidally check the configuration file
             schedule();
 
             // Make sure the root Logger has loaded
-            Logger.getRootLogger();
-
-            // set the root logger level
-            if (rootLoggerLevel != null) {
-                Logger.getRootLogger().setLevel(rootLoggerLevel);
-            }
+            LogManager.getRootLogger();
 
             reconfigure();
         }
 
         // Change all of the loggers over to use log4j
-        GeronimoLogFactory logFactory = (GeronimoLogFactory) LogFactory.getFactory();
-        synchronized (logFactory) {
-            if (!(logFactory.getLogFactory() instanceof CachingLog4jLogFactory)) {
-                logFactory.setLogFactory(new CachingLog4jLogFactory());
+        GeronimoLogFactory geronimoLogFactory = (GeronimoLogFactory) logFactory;
+        synchronized (geronimoLogFactory) {
+            if (!(geronimoLogFactory.getLogFactory() instanceof CachingLog4jLogFactory))
{
+                geronimoLogFactory.setLogFactory(new CachingLog4jLogFactory());
             }
         }
 
@@ -279,9 +381,9 @@
         doStop();
     }
 
-    private synchronized URL resolveURL() {
+    private synchronized File resolveConfigurationFile() {
         try {
-            return serverInfo.resolve(URI.create(configurationFile)).toURL();
+            return serverInfo.resolve(configurationFile);
         } catch (Exception e) {
             return null;
         }
@@ -296,12 +398,12 @@
                         return;
                     }
 
-                    URL url = resolveURL();
-                    if (url == null) {
+                    File file = resolveConfigurationFile();
+                    if (file == null) {
                         return;
                     }
-                    URLConnection connection = url.openConnection();
-                    lastModified = connection.getLastModified();
+
+                    lastModified = file.lastModified();
                 }
 
                 if (lastChanged < lastModified) {
@@ -345,17 +447,19 @@
     static {
         GBeanInfoBuilder infoFactory = new GBeanInfoBuilder(Log4jService.class);
 
-        infoFactory.addAttribute("rootLoggerLevel", String.class, true);
         infoFactory.addAttribute("configurationFile", String.class, true);
         infoFactory.addAttribute("refreshPeriod", int.class, true);
+        infoFactory.addAttribute("configuration", String.class, false);
+        infoFactory.addAttribute("rootLoggerLevel", String.class, false);
 
         infoFactory.addReference("ServerInfo", ServerInfo.class);
 
         infoFactory.addOperation("reconfigure");
         infoFactory.addOperation("setLoggerLevel", new Class[]{String.class, String.class});
         infoFactory.addOperation("getLoggerLevel", new Class[]{String.class});
+        infoFactory.addOperation("getLoggerEffectiveLevel", new Class[]{String.class});
 
-        infoFactory.setConstructor(new String[]{"rootLoggerLevel", "configurationFile", "refreshPeriod",
"ServerInfo"});
+        infoFactory.setConstructor(new String[]{"configurationFile", "refreshPeriod", "ServerInfo"});
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java
Wed Nov 10 00:15:53 2004
@@ -71,6 +71,7 @@
         if (!base.isDirectory()) {
             throw new IllegalArgumentException("Base directory is not a directory: " + baseDirectory);
         }
+        System.setProperty("geronimo.base.dir", base.getAbsolutePath());
     }
 
     public String resolvePath(final String filename) {

Mime
View raw message