jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [15/27] jena git commit: Decouple FusekiLogging from the webapp.
Date Fri, 31 Aug 2018 12:05:05 GMT
Decouple FusekiLogging from the webapp.

Pass in an addition allocation to look for a log4j1 properties file.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/24901120
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/24901120
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/24901120

Branch: refs/heads/master
Commit: 2490112032af274391c4b6bca558ff358ce34c3c
Parents: 689c4cf
Author: Andy Seaborne <andy@apache.org>
Authored: Sat Aug 25 17:12:12 2018 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Sat Aug 25 17:12:12 2018 +0100

----------------------------------------------------------------------
 .../org/apache/jena/fuseki/cmd/FusekiCmd.java     |  5 +++--
 .../apache/jena/fuseki/system/FusekiLogging.java  | 18 +++++++++++++-----
 .../webapp/FusekiServerEnvironmentInit.java       |  5 +++--
 .../java/org/apache/jena/fuseki/TS_Fuseki.java    |  2 +-
 4 files changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/24901120/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
index e62b118..e2957b8 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
@@ -58,8 +58,9 @@ public class FusekiCmd {
     // statics of a class are run.
 
     static {
-        FusekiEnv.mode = FusekiEnv.INIT.STANDALONE ;
-        FusekiLogging.setLogging() ;
+        FusekiEnv.mode = FusekiEnv.INIT.STANDALONE;
+        FusekiEnv.setEnvironment();
+        FusekiLogging.setLogging(FusekiEnv.FUSEKI_BASE);
     }
 
     static public void main(String... argv) {

http://git-wip-us.apache.org/repos/asf/jena/blob/24901120/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/FusekiLogging.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/FusekiLogging.java
b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/FusekiLogging.java
index 404c581..147fbd0 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/FusekiLogging.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/FusekiLogging.java
@@ -20,11 +20,11 @@ package org.apache.jena.fuseki.system;
 
 import java.io.File ;
 import java.net.URL ;
+import java.nio.file.Path;
 
 import org.apache.jena.atlas.lib.StrUtils ;
 import org.apache.jena.atlas.logging.LogCtl ;
 import org.apache.jena.fuseki.Fuseki;
-import org.apache.jena.fuseki.webapp.FusekiEnv;
 import org.apache.jena.riot.SysRIOT ;
 import org.apache.log4j.PropertyConfigurator ;
 import org.apache.log4j.helpers.Loader ;
@@ -65,12 +65,20 @@ public class FusekiLogging
     
     /** Set up logging - standalone and war packaging */
     public static synchronized void setLogging() {
+        setLogging(null);
+        
+    }
+    
+    /** Set up logging. Allow an extra location (string directory name without trailing "/").
This may be null 
+     * 
+     * @param extraDir
+     */
+    public static synchronized void setLogging(Path extraDir) {
         if ( ! allowLoggingReset )
             return ;
         if ( loggingInitialized )
             return ;
         loggingInitialized = true ;
-        FusekiEnv.setEnvironment() ;
         
         logLogging("Fuseki logging") ;
         // No loggers have been created but configuration may have been set up.
@@ -86,12 +94,12 @@ public class FusekiLogging
         }
         logLogging("Fuseki logging - setup") ;
         // Look for a log4j.properties in the current working directory
-        // and an existing FUSEKI_BASE for easy customization.
+        // and a plane (e.g. FUSEKI_BASE in the webapp/full server) for easy customization.
         String fn1 = "log4j.properties" ;
         String fn2 = null ;
         
-        if ( FusekiEnv.FUSEKI_BASE != null ) 
-            fn2 = FusekiEnv.FUSEKI_BASE.toString()+"/log4j.properties" ;
+        if ( extraDir != null ) 
+            fn2 = extraDir.resolve("log4j.properties").toString() ;
         if ( attempt(fn1) ) return ; 
         if ( attempt(fn2) ) return ;
         

http://git-wip-us.apache.org/repos/asf/jena/blob/24901120/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/webapp/FusekiServerEnvironmentInit.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/webapp/FusekiServerEnvironmentInit.java
b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/webapp/FusekiServerEnvironmentInit.java
index b950550..6d3d889 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/webapp/FusekiServerEnvironmentInit.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/webapp/FusekiServerEnvironmentInit.java
@@ -34,9 +34,10 @@ public class FusekiServerEnvironmentInit implements ServletContextListener
{
     
     @Override
     public void contextInitialized(ServletContextEvent sce) {
-        FusekiLogging.setLogging();
-        JenaSystem.init() ;
+        // These two do not touch Jena.
         FusekiEnv.setEnvironment() ;
+        FusekiLogging.setLogging(FusekiEnv.FUSEKI_BASE);
+        JenaSystem.init() ;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/jena/blob/24901120/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
index d3e51c4..42e33df 100644
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
+++ b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
@@ -55,8 +55,8 @@ public class TS_Fuseki extends ServerTest
         FileOps.ensureDir(FusekiTestHome);
         FileOps.clearDirectory(FusekiTestHome);
         System.setProperty("FUSEKI_HOME", FusekiTestHome) ;
-        FusekiLogging.setLogging();
         FusekiEnv.setEnvironment() ;
+        FusekiLogging.setLogging();
         // To avoid confusion with log4j.properties in the main part of the server,
         // we modify in place the logging, not try to set it with another
         // Log4j properties file from the classpath.  


Mime
View raw message