Merge branch 'master' of https://github.com/apache/oodt into development
diff --git a/CHANGES.txt b/CHANGES.txt
index bfca4bf..07078ae 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -25,6 +25,8 @@
 
 * OODT-991 Change logging.properties levels from ALL to DEBUG
 
+* OODT-998 Updated cas-filemgr shell scripts to work when distribution is located in a path with spaces
+
 =======
 Release 1.2.2 - 02/05/2018
 
diff --git a/config/src/main/resources/log4j2.xml b/config/src/main/resources/log4j2.xml
index c2534db..90cf8ba 100644
--- a/config/src/main/resources/log4j2.xml
+++ b/config/src/main/resources/log4j2.xml
@@ -23,7 +23,7 @@
         <Console name="Console" target="SYSTEM_OUT">
             <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
         </Console>
-        <File name="File" fileName="config.log" immediateFlush="false">
+        <File name="File" fileName="config.log" immediateFlush="true">
             <PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
         </File>
     </Appenders>
diff --git a/crawler/src/main/resources/log4j2.xml b/crawler/src/main/resources/log4j2.xml
index 2ae438c..4afb492 100644
--- a/crawler/src/main/resources/log4j2.xml
+++ b/crawler/src/main/resources/log4j2.xml
@@ -23,7 +23,7 @@
         <Console name="Console" target="SYSTEM_OUT">
             <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
         </Console>
-        <File name="File" fileName="../logs/cas_crawler_log.log" immediateFlush="false">
+        <File name="File" fileName="../logs/cas_crawler_log.log" immediateFlush="true">
             <PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
         </File>
     </Appenders>
diff --git a/filemgr/src/main/resources/log4j2.xml b/filemgr/src/main/resources/log4j2.xml
index 213b5aa..6bb7339 100644
--- a/filemgr/src/main/resources/log4j2.xml
+++ b/filemgr/src/main/resources/log4j2.xml
@@ -23,13 +23,14 @@
         <Console name="Console" target="SYSTEM_OUT">
             <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
         </Console>
-        <File name="File" fileName="../logs/cas_file_mgr.log" immediateFlush="false">
+        <File name="File" fileName="../logs/cas_file_mgr.log" immediateFlush="true">
             <PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
         </File>
     </Appenders>
 
     <Loggers>
         <Logger name="org.springframework" level="error"/>
+        <Logger name="org.jboss.netty" level="error"/>
 
         <Root level="debug">
             <AppenderRef ref="Console"/>
diff --git a/resource/pom.xml b/resource/pom.xml
index 38343a5..6f1ebdd 100644
--- a/resource/pom.xml
+++ b/resource/pom.xml
@@ -139,7 +139,7 @@
             <phase>package</phase>
           </execution>
         </executions>
-      </plugin>  
+      </plugin>
     </plugins>
   </build>
   <dependencies>
@@ -202,6 +202,11 @@
       <groupId>commons-pool</groupId>
       <artifactId>commons-pool</artifactId>
     </dependency>
+    <!-- Logging - JUL to SLF4J -->
+    <dependency>
+       <groupId>org.slf4j</groupId>
+       <artifactId>jul-to-slf4j</artifactId>
+    </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
diff --git a/resource/src/main/assembly/assembly.xml b/resource/src/main/assembly/assembly.xml
index c753724..f0ac5a6 100644
--- a/resource/src/main/assembly/assembly.xml
+++ b/resource/src/main/assembly/assembly.xml
@@ -52,6 +52,7 @@
       <includes>
         <include>resource.properties</include>
         <include>logging.properties</include>
+        <include>log4j2.xml</include>
       </includes>
     </fileSet>
     <fileSet>
@@ -67,6 +68,14 @@
       <outputDirectory>policy</outputDirectory>
       <excludes/>
     </fileSet>
+    <!-- Create /run directory to store PID -->
+    <fileSet>
+      <directory>${basedir}/src/main/resources/examples</directory>
+      <outputDirectory>run</outputDirectory>
+      <excludes>
+        <exclude>**/*</exclude>
+      </excludes>
+    </fileSet>
     <fileSet>
       <directory>target/site/apidocs</directory>
       <filtered>false</filtered>
diff --git a/resource/src/main/bin/resmgr b/resource/src/main/bin/resmgr
index 1ca4978..db948f8 100644
--- a/resource/src/main/bin/resmgr
+++ b/resource/src/main/bin/resmgr
@@ -36,9 +36,9 @@
 export JAVA_HOME
 CAS_RESMGR_HOME=..
 export CAS_RESMGR_HOME
-RUN_HOME=${CAS_RESMGR_HOME}/../run
+RUN_HOME=${CAS_RESMGR_HOME}/run
 export RUN_HOME
-CAS_RESMGR_PROPS=../etc/resource.properties
+CAS_RESMGR_PROPS=${CAS_RESMGR_HOME}/etc/resource.properties
 export CAS_RESMGR_PROPS
 
 PATH=${JAVA_HOME}/bin:${CAS_RESMGR_HOME}/bin:/usr/bin:/bin:/usr/sbin:/sbin
@@ -50,6 +50,7 @@
         echo -n "Starting cas resource manager: "
         $JAVA_HOME/bin/java -Djava.ext.dirs=${CAS_RESMGR_HOME}/lib \
         -Djava.util.logging.config.file=${CAS_RESMGR_HOME}/etc/logging.properties \
+        -Dlog4j.configurationFile=${CAS_RESMGR_HOME}/etc/log4j2.xml \
         -Dorg.apache.oodt.cas.resource.properties=${CAS_RESMGR_PROPS} \
         org.apache.oodt.cas.resource.system.ResourceManagerMain --portNum $SERVER_PORT &
         echo $! >${RUN_HOME}/cas.resmgr.pid 
diff --git a/resource/src/main/bin/resmgr-client b/resource/src/main/bin/resmgr-client
index 0376b66..d8f64fb 100644
--- a/resource/src/main/bin/resmgr-client
+++ b/resource/src/main/bin/resmgr-client
@@ -29,6 +29,7 @@
         -Djava.ext.dirs=../lib \
         -Dorg.apache.oodt.cas.resource.properties=../etc/resource.properties \
         -Djava.util.logging.config.file=../etc/logging.properties \
+        -Dlog4j.configurationFile=../etc/log4j2.xml \
         -Dorg.apache.oodt.cas.cli.action.spring.config=../policy/cmd-line-actions.xml \
         -Dorg.apache.oodt.cas.cli.option.spring.config=../policy/cmd-line-options.xml \
         org.apache.oodt.cas.resource.system.ResourceManagerClientMain $*
diff --git a/resource/src/main/resources/log4j2.xml b/resource/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..80bbf2b
--- /dev/null
+++ b/resource/src/main/resources/log4j2.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ 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.
+  -->
+
+<Configuration status="INFO">
+
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <RollingFile name="RollingFile" fileName="../logs/cas_resmgr.log"
+                     filePattern="../logs/cas_resmgr-%i.log">
+            <PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+            <Policies>
+                <OnStartupTriggeringPolicy/>
+                <SizeBasedTriggeringPolicy size="10 MB"/>
+            </Policies>
+            <DefaultRolloverStrategy max="10"/>
+        </RollingFile>
+    </Appenders>
+
+    <Loggers>
+        <Logger name="org.springframework" level="error"/>
+        <Logger name="org.mortbay" level="error"/>
+
+        <Root level="info">
+            <AppenderRef ref="Console"/>
+            <AppenderRef ref="RollingFile"/>
+        </Root>
+    </Loggers>
+</Configuration>
\ No newline at end of file
diff --git a/resource/src/main/resources/logging.properties b/resource/src/main/resources/logging.properties
index a7a3da0..c417673 100644
--- a/resource/src/main/resources/logging.properties
+++ b/resource/src/main/resources/logging.properties
@@ -17,25 +17,17 @@
 # Specify the handlers to create in the root logger
 # (all loggers are children of the root logger)
 # The following creates two handlers
-handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
+handlers = org.slf4j.bridge.SLF4JBridgeHandler
 
+# =================================================
+# Use "logj2.xml" to set log levels if SLF4JBridgeHandler is used.
+# ===========================================
 # Set the default logging level for the root logger
-.level = DEBUG
+# .level = DEBUG
     
-# Set the default logging level for new ConsoleHandler instances
-java.util.logging.ConsoleHandler.level = DEBUG
-java.util.logging.FileHandler.level = DEBUG
-        
-# Set the default formatter for new ConsoleHandler instances
-java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+# Set the default logging level for SLF4JBridgeHandler instances
+# org.slf4j.bridge.SLF4JBridgeHandler.level = DEBUG
 
-# default file output is in user's home directory.
-java.util.logging.FileHandler.pattern = ../logs/cas_resource%g.log
-java.util.logging.FileHandler.limit = 50000
-java.util.logging.FileHandler.count = 5
-java.util.logging.FileHandler.append = true
-java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
-    
 # Set the default logging level for the subsystems
 
 # batchmgr subsystem