You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2014/12/18 20:07:03 UTC
jena git commit: Isolate default logging setup
Repository: jena
Updated Branches:
refs/heads/master 19f917ed1 -> 60983cb6c
Isolate default logging setup
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/60983cb6
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/60983cb6
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/60983cb6
Branch: refs/heads/master
Commit: 60983cb6c994527eb6d414042f32e96de8a0517c
Parents: 19f917e
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Dec 18 18:59:31 2014 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Dec 18 19:01:35 2014 +0000
----------------------------------------------------------------------
.../org/apache/jena/fuseki/FusekiLogging.java | 77 ++++++++++----------
.../src/main/resources/log4j.properties | 49 -------------
.../org/apache/jena/fuseki/log4j.properties | 41 +++++++++++
3 files changed, 78 insertions(+), 89 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/60983cb6/jena-fuseki2/src/main/java/org/apache/jena/fuseki/FusekiLogging.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/src/main/java/org/apache/jena/fuseki/FusekiLogging.java b/jena-fuseki2/src/main/java/org/apache/jena/fuseki/FusekiLogging.java
index 8bab4f1..ab2fa81 100644
--- a/jena-fuseki2/src/main/java/org/apache/jena/fuseki/FusekiLogging.java
+++ b/jena-fuseki2/src/main/java/org/apache/jena/fuseki/FusekiLogging.java
@@ -32,16 +32,21 @@ public class FusekiLogging
// This class must not have static constants, or otherwise not use "Fuseki.*"
// or any class else where that might kick off logging. Otherwise, the
// setLogging is poiintless (it's already set).
- // PlanB - reinitilize logging regardless on first call.
-
+ // PlanB - reinitialize logging regardless on first call.
// Set logging.
// 1/ Use log4j.configuration if defined.
// 2/ Use file:log4j.properties if exists
// 3/ Use log4j.properties on the classpath.
- // 4/ Use Built in.
- // Using FusekiCmd causes
-
+ // 4/ Use built-in org/apache/jena/fuseki/log4j.properties on the classpath.
+ // 5/ Use Built in string
+
+ /** Places for the log4j properties file at (3) */
+ private static final String[] resourcesForLog4jProperties = {
+ "log4j.properties",
+ "org/apache/jena/fuseki/log4j.properties"
+ } ;
+
private static final boolean LogLogging = false ;
private static boolean loggingInitialized = false ;
@@ -66,7 +71,6 @@ public class FusekiLogging
// Look for a log4j.properties in the current working directory for easy
// customization.
try {
- logLogging("Fuseki logging - look for file:log4j.properties") ;
String fn = "log4j.properties" ;
File f = new File(fn) ;
if ( f.exists() ) {
@@ -75,27 +79,27 @@ public class FusekiLogging
System.setProperty("log4j.configuration", "file:" + fn) ;
return ;
}
- logLogging("Fuseki logging - no local log4j.properties") ;
}
catch (Throwable th) {}
- // Try log4j.properties
-
- // The log4j general initialization is done in a class static
- // in LogManager so it can't be called again in any sensible manner.
- // Instead, we include the same basic mechanism ...
- logLogging("Fuseki logging - classpath log4j.properties") ;
- URL url = Loader.getResource("log4j.properties") ;
- if ( url != null ) {
- PropertyConfigurator.configure(url) ;
- logLogging("Fuseki logging - found via classpath %s", url) ;
- System.setProperty("log4j.configuration", url.toString()) ;
- return ;
+ // Try classpath
+ for ( String resourceName : resourcesForLog4jProperties ) {
+ // The log4j general initialization is done in a class static
+ // in LogManager so it can't be called again in any sensible manner.
+ // Instead, we include the same basic mechanism ...
+ logLogging("Fuseki logging - classpath %s", resourceName) ;
+ URL url = Loader.getResource(resourceName) ;
+ if ( url != null ) {
+ PropertyConfigurator.configure(url) ;
+ logLogging("Fuseki logging - found via classpath %s", url) ;
+ System.setProperty("log4j.configuration", url.toString()) ;
+ return ;
+ }
}
-
- logLogging("Fuseki logging - Use built-in") ;
// Use builtin.
- LogCtl.resetLogging(log4Jsetup()) ;
+ logLogging("Fuseki logging - Fallback log4j.properties string") ;
+ String dftLog4j = log4JsetupFallback() ;
+ LogCtl.resetLogging(dftLog4j);
// Stop anything attempting to do it again.
System.setProperty("log4j.configuration", "set") ;
}
@@ -107,7 +111,7 @@ public class FusekiLogging
}
}
- private static String log4Jsetup() {
+ private static String log4JsetupFallback() {
return StrUtils.strjoinNL
// Preferred: classes/log4j.properties, from src/main/resources/log4j.properties
// Keep these in-step. Different usages cause different logging initalizations;
@@ -119,22 +123,19 @@ public class FusekiLogging
"log4j.appender.jena.plainstdout.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %-10c{1} %-5p %m%n",
//"log4j.appender.jena.plainstdout.layout.ConversionPattern=%d{HH:mm:ss} %-10c{1} %-5p %m%n",
- "## Plain output to stderr",
- "log4j.appender.jena.plainstderr=org.apache.log4j.ConsoleAppender",
- "log4j.appender.jena.plainstderr.target=System.err",
- "log4j.appender.jena.plainstderr.layout=org.apache.log4j.PatternLayout",
- //"log4j.appender.jena.plainstderr.layout.ConversionPattern=%d{HH:mm:ss} %-10c{1} %-5p %m%n",
- "log4j.appender.jena.plainstderr.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %-10c{1} %-5p %m%n",
-
- "## Everything",
+ "# Unadorned, for the requests log.",
+ "log4j.appender.fuseki.plain=org.apache.log4j.ConsoleAppender",
+ "log4j.appender.fuseki.plain.target=System.out",
+ "log4j.appender.fuseki.plain.layout=org.apache.log4j.PatternLayout",
+ "log4j.appender.fuseki.plain.layout.ConversionPattern=%m%n",
+
+ "## Most things",
"log4j.rootLogger=INFO, jena.plainstdout",
"log4j.logger.com.hp.hpl.jena=WARN",
"log4j.logger.org.openjena=WARN",
"log4j.logger.org.apache.jena=WARN",
- "log4j.logger.org.apache.jena=WARN",
-
- "# System logs.",
+ "# Fuseki System logs.",
"log4j.logger." + Fuseki.serverLogName + "=INFO",
"log4j.logger." + Fuseki.actionLogName + "=INFO",
"log4j.logger." + Fuseki.adminLogName + "=INFO",
@@ -145,13 +146,9 @@ public class FusekiLogging
"log4j.logger.org.eclipse.jetty=WARN" ,
"log4j.logger.org.apache.shiro=WARN",
- "# NCSA RequestAccess log",
- "log4j.appender.plain=org.apache.log4j.ConsoleAppender",
- "log4j.appender.plain.target=System.out",
- "log4j.appender.plain.layout=org.apache.log4j.PatternLayout",
- "log4j.appender.plain.layout.ConversionPattern=%m%n",
+ "# NCSA Request Access log",
"log4j.additivity."+Fuseki.requestLogName + "=false",
- "log4j.logger."+Fuseki.requestLogName + "=INFO, plain",
+ "log4j.logger."+Fuseki.requestLogName + "=OFF, fuseki.plain",
"## Parser output",
"log4j.additivity" + SysRIOT.riotLoggerName + "=false",
http://git-wip-us.apache.org/repos/asf/jena/blob/60983cb6/jena-fuseki2/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/jena-fuseki2/src/main/resources/log4j.properties b/jena-fuseki2/src/main/resources/log4j.properties
deleted file mode 100644
index c7f8bb3..0000000
--- a/jena-fuseki2/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,49 +0,0 @@
-# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
-
-# Plain output to stdout
-log4j.appender.jena.plainstdout=org.apache.log4j.ConsoleAppender
-log4j.appender.jena.plainstdout.target=System.out
-log4j.appender.jena.plainstdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.jena.plainstdout.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %-10c{1} %-5p %m%n
-##
-## %d{ISO8601} -- includes "ss,sss"
-## log4j.appender.jena.plainstdout.layout.ConversionPattern=[%d{ISO8601}] %-10c{1} %-5p %m%n
-
-# Plain output to stderr
-log4j.appender.jena.plainstderr=org.apache.log4j.ConsoleAppender
-log4j.appender.jena.plainstderr.target=System.err
-log4j.appender.jena.plainstderr.layout=org.apache.log4j.PatternLayout
-log4j.appender.jena.plainstderr.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %-10c{1} %-5p %m%n
-
-# Unadorned, for the requests log.
-log4j.appender.fuseki.plain=org.apache.log4j.ConsoleAppender
-log4j.appender.fuseki.plain.target=System.out
-log4j.appender.fuseki.plain.layout=org.apache.log4j.PatternLayout
-log4j.appender.fuseki.plain.layout.ConversionPattern=%m%n
-
-log4j.rootLogger=INFO, jena.plainstdout
-log4j.logger.com.hp.hpl.jena=WARN
-log4j.logger.org.apache.jena=WARN
-log4j.logger.org.apache.jena.fuseki=INFO
-
-# Others
-log4j.logger.org.eclipse.jetty=WARN
-log4j.logger.org.apache.shiro=WARN
-
-# Fuseki System logs.
-log4j.logger.org.apache.jena.fuseki.Server=INFO
-log4j.logger.org.apache.jena.fuseki.Fuseki=INFO
-log4j.logger.org.apache.jena.fuseki.Admin=INFO
-log4j.logger.org.apache.jena.fuseki.Validate=INFO
-log4j.logger.org.apache.jena.fuseki.Config=INFO
-
-# NCSA Request log.
-log4j.appender.plain.layout.ConversionPattern=%m%n
-log4j.additivity.org.apache.jena.fuseki.Request=false
-log4j.logger.org.apache.jena.fuseki.Request=INFO, fuseki.plain
-
-# TDB
-log4j.logger.org.apache.jena.tdb.loader=INFO
-## Parser output
-log4j.additivity.org.apache.jena.riot=false
-log4j.logger.org.apache.jena.riot=INFO, jena.plainstdout
http://git-wip-us.apache.org/repos/asf/jena/blob/60983cb6/jena-fuseki2/src/main/resources/org/apache/jena/fuseki/log4j.properties
----------------------------------------------------------------------
diff --git a/jena-fuseki2/src/main/resources/org/apache/jena/fuseki/log4j.properties b/jena-fuseki2/src/main/resources/org/apache/jena/fuseki/log4j.properties
new file mode 100644
index 0000000..9570a03
--- /dev/null
+++ b/jena-fuseki2/src/main/resources/org/apache/jena/fuseki/log4j.properties
@@ -0,0 +1,41 @@
+# Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+# Plain output to stdout
+log4j.appender.jena.plainstdout=org.apache.log4j.ConsoleAppender
+log4j.appender.jena.plainstdout.target=System.out
+log4j.appender.jena.plainstdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.jena.plainstdout.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %-10c{1} %-5p %m%n
+## %d{ISO8601} -- includes "ss,sss"
+## log4j.appender.jena.plainstdout.layout.ConversionPattern=[%d{ISO8601}] %-10c{1} %-5p %m%n
+
+# Unadorned, for the NCSA requests log.
+log4j.appender.fuseki.plain=org.apache.log4j.ConsoleAppender
+log4j.appender.fuseki.plain.target=System.out
+log4j.appender.fuseki.plain.layout=org.apache.log4j.PatternLayout
+log4j.appender.fuseki.plain.layout.ConversionPattern=%m%n
+
+log4j.rootLogger=INFO, jena.plainstdout
+log4j.logger.com.hp.hpl.jena=WARN
+log4j.logger.org.apache.jena=WARN
+log4j.logger.org.apache.jena.fuseki=INFO
+
+# Others
+log4j.logger.org.eclipse.jetty=WARN
+log4j.logger.org.apache.shiro=WARN
+
+# Fuseki System logs.
+log4j.logger.org.apache.jena.fuseki.Server=INFO
+log4j.logger.org.apache.jena.fuseki.Fuseki=INFO
+log4j.logger.org.apache.jena.fuseki.Admin=INFO
+log4j.logger.org.apache.jena.fuseki.Validate=INFO
+log4j.logger.org.apache.jena.fuseki.Config=INFO
+
+# NCSA Request log.
+log4j.additivity.org.apache.jena.fuseki.Request=false
+log4j.logger.org.apache.jena.fuseki.Request=OFF, fuseki.plain
+
+# TDB
+log4j.logger.org.apache.jena.tdb.loader=INFO
+## Parser output
+log4j.additivity.org.apache.jena.riot=false
+log4j.logger.org.apache.jena.riot=INFO, jena.plainstdout