public abstract class Logger extends RocksCallbackObject implements LoggerInterface
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)
Deprecated.
Use
Logger(InfoLogLevel) instead, e.g. new
Logger(dbOptions.infoLogLevel()) . |
Logger(InfoLogLevel logLevel)
AbstractLogger constructor.
|
Logger(Options options)
Deprecated.
Use
Logger(InfoLogLevel) instead, e.g. new
Logger(options.infoLogLevel()) . |
Modifier and Type | Method and Description |
---|---|
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. |
LoggerType |
getLoggerType()
Get the type of this logger.
|
long |
getNativeHandle()
Get the underlying Native Handle.
|
InfoLogLevel |
infoLogLevel()
Get the 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 logLevel,
java.lang.String logMsg) |
protected long |
newLogger(long logLevel) |
void |
setInfoLogLevel(InfoLogLevel logLevel)
Set the log level.
|
protected void |
setInfoLogLevel(long handle,
byte logLevel) |
close, disOwnNativeHandle, isOwningHandle
@Deprecated public Logger(Options options)
Logger(InfoLogLevel)
instead, e.g. new
Logger(options.infoLogLevel())
.AbstractLogger constructor.
Important: the log level set within
the Options
instance will be used as
maximum log level of RocksDB.
options
- Options
instance.@Deprecated public Logger(DBOptions dboptions)
Logger(InfoLogLevel)
instead, e.g. new
Logger(dbOptions.infoLogLevel())
.AbstractLogger constructor.
Important: the log level set within
the DBOptions
instance will be used
as maximum log level of RocksDB.
dboptions
- DBOptions
instance.public Logger(InfoLogLevel logLevel)
AbstractLogger constructor.
logLevel
- the log level.protected long initializeNative(long... nativeParameterHandles)
RocksCallbackObject
initializeNative
in class RocksCallbackObject
nativeParameterHandles
- An array of native handles for any parameter
objects that are needed during constructionpublic void setInfoLogLevel(InfoLogLevel logLevel)
LoggerInterface
setInfoLogLevel
in interface LoggerInterface
logLevel
- the level at which to log.public InfoLogLevel infoLogLevel()
LoggerInterface
infoLogLevel
in interface LoggerInterface
public long getNativeHandle()
LoggerInterface
getNativeHandle
in interface LoggerInterface
public final LoggerType getLoggerType()
LoggerInterface
getLoggerType
in interface LoggerInterface
protected abstract void log(InfoLogLevel logLevel, java.lang.String logMsg)
protected long newLogger(long logLevel)
protected void setInfoLogLevel(long handle, byte logLevel)
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_ptr.disposeInternal
in class RocksCallbackObject