public abstract class Logger extends AbstractImmutableNativeReference
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
.
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()
Deletes underlying C++ slice pointer.
|
InfoLogLevel |
infoLogLevel()
Return the loggers log level.
|
protected byte |
infoLogLevel(long handle) |
protected abstract void |
log(InfoLogLevel infoLogLevel,
java.lang.String logMsg) |
void |
setInfoLogLevel(InfoLogLevel infoLogLevel)
Set
InfoLogLevel to AbstractLogger. |
protected void |
setInfoLogLevel(long handle,
byte infoLogLevel) |
close, disOwnNativeHandle, isOwningHandle
dispose, finalize
public 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.public void setInfoLogLevel(InfoLogLevel infoLogLevel)
InfoLogLevel
to AbstractLogger.infoLogLevel
- InfoLogLevel
instance.public InfoLogLevel infoLogLevel()
InfoLogLevel
instance.protected abstract void log(InfoLogLevel infoLogLevel, java.lang.String logMsg)
protected void disposeInternal()
disposeInternal
in class AbstractImmutableNativeReference
protected long createNewLoggerOptions(long options)
protected long createNewLoggerDbOptions(long dbOptions)
protected void setInfoLogLevel(long handle, byte infoLogLevel)
protected byte infoLogLevel(long handle)