|
|
|
@ -50,35 +50,35 @@ import java.lang.reflect.InvocationTargetException;
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* A logging framework wrapper that supports java.util.logging and log4j. |
|
|
|
|
* <P/> |
|
|
|
|
* <p/> |
|
|
|
|
* Logger hierarchies are stored at the Class level. |
|
|
|
|
* Log4j will be used if the Log4j system (not necessarily config files) are |
|
|
|
|
* found in the runtime classpath. |
|
|
|
|
* Otherwise, java.util.logging will be used. |
|
|
|
|
* <P/> |
|
|
|
|
* <p/> |
|
|
|
|
* This is pretty safe because for use cases where multiple hierarchies |
|
|
|
|
* are desired, classloader hierarchies will effectively isolate multiple |
|
|
|
|
* class-level Logger hierarchies. |
|
|
|
|
* <P/> |
|
|
|
|
* <p/> |
|
|
|
|
* Sad as it is, the java.util.logging facility lacks the most basic |
|
|
|
|
* developer-side and configuration-side capabilities. |
|
|
|
|
* Besides having a non-scalable discovery system, the designers didn't |
|
|
|
|
* comprehend the need for a level between WARNING and SEVERE! |
|
|
|
|
* Since we don't want to require log4j in Classpath, we have to live |
|
|
|
|
* with these constraints. |
|
|
|
|
* <P/> |
|
|
|
|
* <p/> |
|
|
|
|
* As with all the popular logging frameworks, if you want to capture a |
|
|
|
|
* stack trace, you must use the two-parameters logging methods. |
|
|
|
|
* I.e., you must also pass a String, or only toString() from your |
|
|
|
|
* throwable will be captured. |
|
|
|
|
* <P/> |
|
|
|
|
* <p/> |
|
|
|
|
* Usage example:<CODE><PRE> |
|
|
|
|
* private static FrameworkLogger logger = |
|
|
|
|
* FrameworkLogger.getLog(SqlTool.class); |
|
|
|
|
* ... |
|
|
|
|
* logger.finer("Doing something log-worthy"); |
|
|
|
|
* </PRE> </CODE> |
|
|
|
|
* |
|
|
|
|
* <p> |
|
|
|
|
* <p/> |
|
|
|
|
* The system level property <code>hsqldb.reconfig_logging=false</code> is |
|
|
|
|
* required to avoid configuration of java.util.logging. Otherwise |
|
|
|
@ -131,7 +131,8 @@ public class FrameworkLogger {
|
|
|
|
|
static { |
|
|
|
|
try { |
|
|
|
|
reconfigure(); |
|
|
|
|
} catch (SecurityException e) {} |
|
|
|
|
} catch (SecurityException e) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -219,9 +220,9 @@ public class FrameworkLogger {
|
|
|
|
|
try { |
|
|
|
|
// log4j v2 available?
|
|
|
|
|
log4jLoggerClass = Class.forName( |
|
|
|
|
"org.apache.logging.log4j.Logger"); |
|
|
|
|
"com.fr.third.apache.logging.log4j.Logger"); |
|
|
|
|
log4jManagerClass = Class.forName( |
|
|
|
|
"org.apache.logging.log4j.LogManager"); |
|
|
|
|
"com.fr.third.apache.logging.log4j.LogManager"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
|
|
// The class will only load successfully if Log4j v2 thinks it is
|
|
|
|
@ -232,11 +233,11 @@ public class FrameworkLogger {
|
|
|
|
|
// Attempt to configure log4j v2
|
|
|
|
|
if (log4jLoggerClass != null) { |
|
|
|
|
try { |
|
|
|
|
populateJdkToLog4jLevels("org.apache.logging.log4j.Level"); |
|
|
|
|
populateJdkToLog4jLevels("com.fr.third.apache.logging.log4j.Level"); |
|
|
|
|
|
|
|
|
|
log4jLogMethod = log4jLoggerClass.getMethod("log", |
|
|
|
|
new Class[]{ |
|
|
|
|
Class.forName("org.apache.logging.log4j.Level"), |
|
|
|
|
Class.forName("com.fr.third.apache.logging.log4j.Level"), |
|
|
|
|
Object.class, Throwable.class |
|
|
|
|
}); |
|
|
|
|
log4jGetLogger = log4jManagerClass.getMethod("getLogger", |
|
|
|
@ -272,7 +273,7 @@ public class FrameworkLogger {
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
// log4j v1 available?
|
|
|
|
|
log4jLoggerClass = Class.forName("org.apache.log4j.Logger"); |
|
|
|
|
log4jLoggerClass = Class.forName("com.fr.third.apache.log4j.Logger"); |
|
|
|
|
log4jManagerClass = log4jLoggerClass; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
|
@ -284,11 +285,11 @@ public class FrameworkLogger {
|
|
|
|
|
// Attempt to configure log4j v1
|
|
|
|
|
if (log4jLoggerClass != null) { |
|
|
|
|
try { |
|
|
|
|
populateJdkToLog4jLevels("org.apache.log4j.Level"); |
|
|
|
|
populateJdkToLog4jLevels("com.fr.third.apache.log4j.Level"); |
|
|
|
|
|
|
|
|
|
log4jLogMethod = log4jLoggerClass.getMethod("log", |
|
|
|
|
new Class[]{ |
|
|
|
|
String.class, Class.forName("org.apache.log4j.Priority"), |
|
|
|
|
String.class, Class.forName("com.fr.third.apache.log4j.Priority"), |
|
|
|
|
Object.class, Throwable.class |
|
|
|
|
}); |
|
|
|
|
log4jGetLogger = log4jManagerClass.getMethod("getLogger", |
|
|
|
@ -350,7 +351,7 @@ public class FrameworkLogger {
|
|
|
|
|
|
|
|
|
|
lm.readConfiguration(istream); |
|
|
|
|
|
|
|
|
|
Logger cmdlineLogger = Logger.getLogger("org.hsqldb.cmdline"); |
|
|
|
|
Logger cmdlineLogger = Logger.getLogger("com.fr.third.org.hsqldb.cmdline"); |
|
|
|
|
|
|
|
|
|
cmdlineLogger.addHandler(consoleHandler); |
|
|
|
|
cmdlineLogger.setUseParentHandlers(false); |
|
|
|
@ -412,7 +413,7 @@ public class FrameworkLogger {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* User's entry-point into this logging system. |
|
|
|
|
* <P/> |
|
|
|
|
* <p/> |
|
|
|
|
* You normally want to work with static (class-level) pointers to |
|
|
|
|
* logger instances, for performance efficiency. |
|
|
|
|
* See the class-level JavaDoc for a usage example. |
|
|
|
@ -679,7 +680,7 @@ public class FrameworkLogger {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Whether this JVM is configured with java.util.logging defaults. |
|
|
|
|
* |
|
|
|
|
* <p> |
|
|
|
|
* If the JRE-provided config file is not in the expected place, then |
|
|
|
|
* we return false. |
|
|
|
|
*/ |
|
|
|
|