Package com.nuodb.jdbc.logger
Class Jdk14Logger
- java.lang.Object
-
- com.nuodb.jdbc.logger.Jdk14Logger
-
- All Implemented Interfaces:
Logger
public class Jdk14Logger extends Object implements Logger
Jdk14Logger is controller by java.util.logging.LogManager, which uses java.util.logging.config.file system property to load config file. If this property is not specified, then the config file is retrieved from its default location at $JAVA_HOME/jre/lib/logging.properties. The default config file uses INFO level for all loggers and having that exceptions are printed using WARN level by ConsoleHandler, you'll see log records without custom config file. Here is example using custom config file:# example of custom logging.properties for com.nuodb.jdbc.logger.Jdk14Logger handlers=java.util.logging.ConsoleHandler # Default global logging level # Loggers and Handlers may override this level .level=INFO # Loggers, these are usually attached to packages # Here, the level for each package is specified. package.name1.level=ALL package.name2.level=SEVERE # Handlers # Override global logging level java.util.logging.ConsoleHandler.level=FINE java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
com.nuodb.jdbc.logger.Jdk14Logger will be managed by custom logging.properties:java -Djava.util.logging.config.file=logging.properties Jdk14LoggerTest public class Jdk14LoggerTest { public static void main(String[] args) throws java.sql.SQLException { Connection connection = null; try { String url = "jdbc:com.nuodb://localhost/test?user=dba&password=dba"; // the connection will use com.nuodb.jdbc.logger.Jdk14Logger Properties properties = new Properties(); properties.put("jdk14Logger", "true"); connection = DriverManager.getConnection(url, properties); // this is parent java.util.logging.Logger for all child loggers Logger parentLogger = DriverManager.getDriver(url).getParentLogger(); } finally { if (connection != null) { connection.close(); } } } }- Author:
- Sergey Bushik
-
-
Constructor Summary
Constructors Constructor Description Jdk14Logger(Logger logger)Jdk14Logger(Logger logger, String callerClassName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddebug(String message)voiddebug(String message, Throwable failure)booleanequals(Object o)voiderror(String message)voiderror(String message, Throwable failure)StringgetName()inthashCode()voidinfo(String message)voidinfo(String message, Throwable failure)booleanisDebugEnabled()booleanisErrorEnabled()booleanisInfoEnabled()booleanisLevelEnabled(Level level)booleanisTraceEnabled()booleanisWarnEnabled()voidlog(Level level, String callerClassName, String message, Throwable failure)voidlog(Level level, String message, Throwable failure)StringtoString()voidtrace(String message)voidtrace(String message, Throwable failure)voidwarn(String message)voidwarn(String message, Throwable failure)
-
-
-
Method Detail
-
isErrorEnabled
public boolean isErrorEnabled()
- Specified by:
isErrorEnabledin interfaceLogger
-
isWarnEnabled
public boolean isWarnEnabled()
- Specified by:
isWarnEnabledin interfaceLogger
-
isInfoEnabled
public boolean isInfoEnabled()
- Specified by:
isInfoEnabledin interfaceLogger
-
isDebugEnabled
public boolean isDebugEnabled()
- Specified by:
isDebugEnabledin interfaceLogger
-
isTraceEnabled
public boolean isTraceEnabled()
- Specified by:
isTraceEnabledin interfaceLogger
-
isLevelEnabled
public boolean isLevelEnabled(Level level)
- Specified by:
isLevelEnabledin interfaceLogger
-
-