Author: tterm
Date: Thu Jul 26 04:09:05 2007
New Revision: 559781

URL: http://svn.apache.org/viewvc?view=rev&rev=559781
Log:
SM-854 LogService uses hard-coded path to the log4j.xml file

Modified:
    
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogService.java
    
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogTask.java

Modified: 
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogService.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogService.java?view=diff&rev=559781&r1=559780&r2=559781
==============================================================================
--- 
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogService.java
 (original)
+++ 
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogService.java
 Thu Jul 26 04:09:05 2007
@@ -39,6 +39,8 @@
  */
 public class LogService extends BaseSystemService implements InitializingBean, 
LogServiceMBean {
 
+       private static String DEFAULT_LOG_FILE_NAME = "log4j.xml";
+       
     private boolean autoStart = true;
     private boolean initialized = false;
     private int refreshPeriod = 60; // 60sec
@@ -165,13 +167,8 @@
 
     public void setup() throws JBIException {
         if (!initialized) {
-            if (configUrl != null) {
-                try {
-                    configFileUrl = new URL(configUrl);
-                } catch (MalformedURLException e) {
-                    configFileUrl = null;
-                }
-            }
+               configFileUrl = locateLoggingConfig();
+
             if (configFileUrl != null) {
                 // daemon mode
                 timer = new Timer(true);
@@ -184,7 +181,21 @@
         }
     }
 
-    public MBeanOperationInfo[] getOperationInfos() throws JMException {
+    /** 
+     * Grab the log4j.xml from the CLASSPATH 
+     * 
+     * @return URL of the log4j.xml file 
+     */
+    private URL locateLoggingConfig() {
+               URL log4jConfigUrl = 
ClassLoader.getSystemResource(DEFAULT_LOG_FILE_NAME);
+               
+               if (logger.isDebugEnabled() && log4jConfigUrl != null)
+                       logger.debug("Located logging configuration: " + 
log4jConfigUrl.toString());
+               
+               return log4jConfigUrl;
+       }
+
+       public MBeanOperationInfo[] getOperationInfos() throws JMException {
         OperationInfoHelper helper = new OperationInfoHelper();
         helper.addOperation(getObjectToManage(), "reconfigureLogSystem", 0,
                 "Reconfigure the log4j system");

Modified: 
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogTask.java
URL: 
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogTask.java?view=diff&rev=559781&r1=559780&r2=559781
==============================================================================
--- 
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogTask.java
 (original)
+++ 
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogTask.java
 Thu Jul 26 04:09:05 2007
@@ -55,7 +55,7 @@
             if (lastConfigured < lastModified && url != null && xml) {
                 DOMConfigurator.configure(url);
                 lastConfigured = System.currentTimeMillis();
-                logger.info("log4j system reconfigured");
+                logger.info("Logging system reconfigured using file: " + 
url.toString());
             }
         } catch (Exception ex) {
             logger.error(ex);


Reply via email to