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);
...
logger.finer("Doing something log-worthy");
The system level property hsqldb.reconfig_logging=false is
required to avoid configuration of java.util.logging. Otherwise
configuration takes place.
| Modifier and Type | Field and Description |
|---|---|
| private static boolean | |
| private Logger | |
| private static Map | |
| private static Method | |
| private Object | |
| private static Method | |
| private static Map | |
| private static boolean |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static synchronized void | clearLoggers(String
String prefixToZap)Frees Logger(s), if any, with the specified category, or that begins with the specified prefix + dot. |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public static FrameworkLogger | |
| public static FrameworkLogger | Returns: FrameworkLoggerClass c, String String contextId)This method just defers to the getLog(Class) method unless default (no local configuration) JDK logging is being used; In that case, this method assures that the returned logger has an associated FileHander using the supplied String identifier. |
| public static FrameworkLogger | Returns: FrameworkLoggerString baseId, String String contextId)This method just defers to the getLog(String) method unless default (no local configuration) JDK logging is being used; In that case, this method assures that the returned logger has an associated FileHander using the supplied String identifier. |
| public static synchronized FrameworkLogger | |
| public void | |
| public void | |
| public void | |
| public void | |
| private static synchronized void | |
| public void | |
| pack-priv static void | |
| public static synchronized String | |
| public void | |
| public void | |
| public void | |
| public void |
| callerFqcnAvailable | back to summary |
|---|---|
| private static boolean callerFqcnAvailable | |
| jdkLogger | back to summary |
|---|---|
| private Logger jdkLogger | |
| jdkToLog4jLevels | back to summary |
|---|---|
| private static Map<K, V> jdkToLog4jLevels | |
| log4jGetLogger | back to summary |
|---|---|
| private static Method log4jGetLogger | |
| log4jLogger | back to summary |
|---|---|
| private Object log4jLogger | |
| log4jLogMethod | back to summary |
|---|---|
| private static Method log4jLogMethod | |
| loggerInstances | back to summary |
|---|---|
| private static Map<K, V> loggerInstances | |
| noopMode | back to summary |
|---|---|
| private static boolean noopMode | |
| FrameworkLogger | back to summary |
|---|---|
| private FrameworkLogger(String s) User may not use the constructor.
| |
| clearLoggers | back to summary |
|---|---|
| public static synchronized void clearLoggers(String prefixToZap) Frees Logger(s), if any, with the specified category, or that begins with the specified prefix + dot. Note that as of today, this depends on the underlying logging framework implementation to release the underlying Logger instances. JUL in Sun's JVM uses weak references, so that should be fine. Log4j as of today seems to use strong references (and no API hooks to free anything), so this method will probably have little benefit for Log4j.
| |
| enduserlog | back to summary |
|---|---|
| public void enduserlog(Level level, String message) | |
| error | back to summary |
|---|---|
| public void error(String message) This is just a wrapper for FrameworkLogger.warning(), because java.util.logging lacks a method for this critical purpose.
| |
| error | back to summary |
|---|---|
| public void error(String message, Throwable t) Just like FrameworkLogger.error(String), but also logs a stack trace.
| |
| finer | back to summary |
|---|---|
public void finer(String message)
| |
| finer | back to summary |
|---|---|
| public void finer(String message, Throwable t) Just like FrameworkLogger.finer(String), but also logs a stack trace.
| |
| finest | back to summary |
|---|---|
public void finest(String message)
| |
| finest | back to summary |
|---|---|
| public void finest(String message, Throwable t) Just like FrameworkLogger.finest(String), but also logs a stack trace.
| |
| getLog | back to summary |
|---|---|
| public static FrameworkLogger getLog(Class<T> c) User's entry-point into this logging system. 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.
| |
| getLog | back to summary |
|---|---|
| public static FrameworkLogger getLog(Class<T> c, String contextId) This method just defers to the getLog(Class) method unless default (no local configuration) JDK logging is being used; In that case, this method assures that the returned logger has an associated FileHander using the supplied String identifier.
| |
| getLog | back to summary |
|---|---|
| public static FrameworkLogger getLog(String baseId, String contextId) This method just defers to the getLog(String) method unless default (no local configuration) JDK logging is being used; In that case, this method assures that the returned logger has an associated FileHander using the supplied String identifier.
| |
| getLog | back to summary |
|---|---|
| public static synchronized FrameworkLogger getLog(String s) Alternative entry-point into this logging system, for cases where you want to share a single logger instance among multiple classes, or you want to use multiple logger instances from a single class.
| |
| info | back to summary |
|---|---|
public void info(String message)
| |
| info | back to summary |
|---|---|
| public void info(String message, Throwable t) Just like FrameworkLogger.info(String), but also logs a stack trace.
| |
| log | back to summary |
|---|---|
| public void log(Level level, String message, Throwable t) Just like FrameworkLogger.log(Level, String), but also logs a stack trace.
| |
| log | back to summary |
|---|---|
public void log(Level level, String message)
| |
| populateJdkToLog4jLevels | back to summary |
|---|---|
| private static synchronized void populateJdkToLog4jLevels(String classString) throws ClassNotFoundException, IllegalAccessException, NoSuchMethodException, InvocationTargetException | |
| privlog | back to summary |
|---|---|
| public void privlog(Level level, String message, Throwable t, int revertMethods, Class<T> skipClass) The "priv" prefix is historical. This is for special usage when you need to modify the reported call stack. If you don't know that you want to do this, then you should not use this method. | |
| reconfigure | back to summary |
|---|---|
| pack-priv static void reconfigure() Reconfigure log4j if present. (TODO: Class-presence test is inadequate. Should check Log4j is actuall used). Reconfigure java.util.logging otherwise | |
| report | back to summary |
|---|---|
| public static synchronized String report() Utility method for integrators. Returns a string representation of the active Logger instance keys. Not named similar to 'toString' to avoid ambiguity with instance method toString.
| |
| severe | back to summary |
|---|---|
public void severe(String message)
| |
| severe | back to summary |
|---|---|
| public void severe(String message, Throwable t) Just like FrameworkLogger.severe(String), but also logs a stack trace.
| |
| warning | back to summary |
|---|---|
public void warning(String message)
| |
| warning | back to summary |
|---|---|
| public void warning(String message, Throwable t) Just like FrameworkLogger.warning(String), but also logs a stack trace.
| |