diff --git a/fine-hsqldb/src/main/java/com/fr/third/org/hsqldb/lib/FrameworkLogger.java b/fine-hsqldb/src/main/java/com/fr/third/org/hsqldb/lib/FrameworkLogger.java index f59666b73..54f6dad56 100644 --- a/fine-hsqldb/src/main/java/com/fr/third/org/hsqldb/lib/FrameworkLogger.java +++ b/fine-hsqldb/src/main/java/com/fr/third/org/hsqldb/lib/FrameworkLogger.java @@ -50,35 +50,35 @@ import java.lang.reflect.InvocationTargetException; /** * A logging framework wrapper that supports java.util.logging and log4j. - *
+ * * 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. - * + * * This is pretty safe because for use cases where multiple hierarchies * are desired, classloader hierarchies will effectively isolate multiple * class-level Logger hierarchies. - * + * * 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. - * + * * 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. - * + * * Usage example:
* private static FrameworkLogger logger =
- * FrameworkLogger.getLog(SqlTool.class);
+ * FrameworkLogger.getLog(SqlTool.class);
* ...
- * logger.finer("Doing something log-worthy");
+ * logger.finer("Doing something log-worthy");
*
- *
+ * *
* The system level propertyhsqldb.reconfig_logging=false
is
* required to avoid configuration of java.util.logging. Otherwise
@@ -113,17 +113,17 @@ public class FrameworkLogger {
public static synchronized String report() {
return new StringBuilder().append(loggerInstances.size()).append(
- " logger instances: ").append(
- loggerInstances.keySet()).toString();
+ " logger instances: ").append(
+ loggerInstances.keySet()).toString();
}
- static private Map loggerInstances = new HashMap();
- static private Map jdkToLog4jLevels = new HashMap();
- static private Method log4jGetLogger;
- static private Method log4jLogMethod;
+ static private Map loggerInstances = new HashMap();
+ static private Map jdkToLog4jLevels = new HashMap();
+ static private Method log4jGetLogger;
+ static private Method log4jLogMethod;
static private boolean callerFqcnAvailable = false;
- private Object log4jLogger;
- private Logger jdkLogger;
+ private Object log4jLogger;
+ private Logger jdkLogger;
// No need for more than one static, since we have only one console
static private boolean noopMode; // If true, then logging calls do nothing
@@ -131,7 +131,8 @@ public class FrameworkLogger {
static {
try {
reconfigure();
- } catch (SecurityException e) {}
+ } catch (SecurityException e) {
+ }
}
/**
@@ -148,10 +149,10 @@ public class FrameworkLogger {
*/
public static synchronized void clearLoggers(String prefixToZap) {
- Set targetKeys = new HashSet();
- java.util.Iterator it = loggerInstances.keySet().iterator();
- String k;
- String dottedPrefix = prefixToZap + '.';
+ Set targetKeys = new HashSet();
+ java.util.Iterator it = loggerInstances.keySet().iterator();
+ String k;
+ String dottedPrefix = prefixToZap + '.';
while (it.hasNext()) {
k = (String) it.next();
@@ -165,36 +166,36 @@ public class FrameworkLogger {
}
private static synchronized void
- populateJdkToLog4jLevels(String classString)
+ populateJdkToLog4jLevels(String classString)
throws ClassNotFoundException, IllegalAccessException,
NoSuchMethodException, InvocationTargetException {
Method log4jToLevel = Class.forName(classString).getMethod(
- "toLevel", new Class[]{ String.class });
+ "toLevel", new Class[]{String.class});
jdkToLog4jLevels.put(Level.ALL,
- log4jToLevel.invoke(null,
- new Object[]{ "ALL" }));
+ log4jToLevel.invoke(null,
+ new Object[]{"ALL"}));
jdkToLog4jLevels.put(Level.FINER,
- log4jToLevel.invoke(null,
- new Object[]{ "DEBUG" }));
+ log4jToLevel.invoke(null,
+ new Object[]{"DEBUG"}));
jdkToLog4jLevels.put(Level.WARNING,
- log4jToLevel.invoke(null,
- new Object[]{ "ERROR" }));
+ log4jToLevel.invoke(null,
+ new Object[]{"ERROR"}));
jdkToLog4jLevels.put(Level.SEVERE,
- log4jToLevel.invoke(null,
- new Object[]{ "FATAL" }));
+ log4jToLevel.invoke(null,
+ new Object[]{"FATAL"}));
jdkToLog4jLevels.put(Level.INFO,
- log4jToLevel.invoke(null,
- new Object[]{ "INFO" }));
+ log4jToLevel.invoke(null,
+ new Object[]{"INFO"}));
jdkToLog4jLevels.put(Level.OFF,
- log4jToLevel.invoke(null,
- new Object[]{ "OFF" }));
+ log4jToLevel.invoke(null,
+ new Object[]{"OFF"}));
jdkToLog4jLevels.put(Level.FINEST,
- log4jToLevel.invoke(null,
- new Object[]{ "TRACE" }));
+ log4jToLevel.invoke(null,
+ new Object[]{"TRACE"}));
jdkToLog4jLevels.put(Level.WARNING,
- log4jToLevel.invoke(null,
- new Object[]{ "WARN" }));
+ log4jToLevel.invoke(null,
+ new Object[]{"WARN"}));
}
static void reconfigure() {
@@ -207,8 +208,8 @@ public class FrameworkLogger {
loggerInstances.clear();
jdkToLog4jLevels.clear();
- log4jGetLogger = null;
- log4jLogMethod = null;
+ log4jGetLogger = null;
+ log4jLogMethod = null;
callerFqcnAvailable = false;
// Precedence:
@@ -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,15 +233,15 @@ 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"),
- Object.class, Throwable.class
- });
+ new Class[]{
+ Class.forName("com.fr.third.apache.logging.log4j.Level"),
+ Object.class, Throwable.class
+ });
log4jGetLogger = log4jManagerClass.getMethod("getLogger",
- new Class[]{ String.class });
+ new Class[]{String.class});
// This last object is what we toggle on to generate either
// Log4j or Jdk Logger objects (to wrap).
@@ -251,8 +252,8 @@ public class FrameworkLogger {
// successfully initialized with warnings due to bad config).
try {
System.err.println(
- "* If the JRE-provided config file is not in the expected place, then * we return false. */ public static boolean isDefaultJdkConfig() { File globalCfgFile = new File(System.getProperty("java.home"), - "lib/logging.properties"); + "lib/logging.properties"); if (!globalCfgFile.isFile()) { return false; } FileInputStream fis = null; - LogManager lm = LogManager.getLogManager(); + LogManager lm = LogManager.getLogManager(); try { fis = new FileInputStream(globalCfgFile); @@ -703,14 +704,14 @@ public class FrameworkLogger { defaultProps.load(fis); Enumeration names = defaultProps.propertyNames(); - int i = 0; - String name; - String liveVal; + int i = 0; + String name; + String liveVal; while (names.hasMoreElements()) { i++; - name = (String) names.nextElement(); + name = (String) names.nextElement(); liveVal = lm.getProperty(name); if (liveVal == null) {