public abstract class Logger extends RocksCallbackObject
This class provides a custom logger functionality
in Java which wraps RocksDB logging facilities.
Using this class RocksDB can log with common Java logging APIs like Log4j or Slf4j without keeping database logs in the filesystem.
PerformanceThere are certain performance penalties using a Java
Logger implementation within production code.
A log level can be set using Options or
setInfoLogLevel(InfoLogLevel). The set log level
influences the underlying native code. Each log message is
checked against the set log level and if the log level is more
verbose as the set log level, native allocations will be made
and data structures are allocated.
Every log message which will be emitted by native code will
trigger expensive native to Java transitions. So the preferred
setting for production use is either
InfoLogLevel.ERROR_LEVEL or
InfoLogLevel.FATAL_LEVEL.
nativeHandle_owningHandle_| Constructor and Description |
|---|
Logger(DBOptions dboptions)
AbstractLogger constructor.
|
Logger(Options options)
AbstractLogger constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected long |
createNewLoggerDbOptions(long dbOptions) |
protected long |
createNewLoggerOptions(long options) |
protected void |
disposeInternal()
We override
RocksCallbackObject.disposeInternal()
as disposing of a rocksdb::LoggerJniCallback requires
a slightly different approach as it is a std::shared_ptr |
InfoLogLevel |
infoLogLevel()
Return the loggers log level.
|
protected byte |
infoLogLevel(long handle) |
protected long |
initializeNative(long... nativeParameterHandles)
Construct the Native C++ object which will callback
to our object methods
|
protected abstract void |
log(InfoLogLevel infoLogLevel,
String logMsg) |
void |
setInfoLogLevel(InfoLogLevel infoLogLevel)
Set
InfoLogLevel to AbstractLogger. |
protected void |
setInfoLogLevel(long handle,
byte infoLogLevel) |
close, disOwnNativeHandle, isOwningHandlepublic Logger(Options options)
AbstractLogger constructor.
Important: the log level set within
the Options instance will be used as
maximum log level of RocksDB.
options - Options instance.protected long initializeNative(long... nativeParameterHandles)
RocksCallbackObjectinitializeNative in class RocksCallbackObjectnativeParameterHandles - An array of native handles for any parameter
objects that are needed during constructionpublic void setInfoLogLevel(InfoLogLevel infoLogLevel)
InfoLogLevel to AbstractLogger.infoLogLevel - InfoLogLevel instance.public InfoLogLevel infoLogLevel()
InfoLogLevel instance.protected abstract void log(InfoLogLevel infoLogLevel, String logMsg)
protected long createNewLoggerOptions(long options)
protected long createNewLoggerDbOptions(long dbOptions)
protected void setInfoLogLevel(long handle,
byte infoLogLevel)
protected byte infoLogLevel(long handle)
protected void disposeInternal()
RocksCallbackObject.disposeInternal()
as disposing of a rocksdb::LoggerJniCallback requires
a slightly different approach as it is a std::shared_ptrdisposeInternal in class RocksCallbackObjectCopyright © 2022. All rights reserved.