Class Logger
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public abstract class Logger extends RocksCallbackObject
This class provides a custom logger functionality in Java which wraps
RocksDBlogging 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
Loggerimplementation within production code.A log level can be set using
OptionsorsetInfoLogLevel(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_LEVELorInfoLogLevel.FATAL_LEVEL.
-
-
Field Summary
-
Fields inherited from class org.rocksdb.RocksCallbackObject
nativeHandle_
-
Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected longcreateNewLoggerDbOptions(long dbOptions)protected longcreateNewLoggerOptions(long options)protected voiddisposeInternal()We overrideRocksCallbackObject.disposeInternal()as disposing of a rocksdb::LoggerJniCallback requires a slightly different approach as it is a std::shared_ptrInfoLogLevelinfoLogLevel()Return the loggers log level.protected byteinfoLogLevel(long handle)protected longinitializeNative(long... nativeParameterHandles)Construct the Native C++ object which will callback to our object methodsprotected abstract voidlog(InfoLogLevel infoLogLevel, java.lang.String logMsg)protected voidsetInfoLogLevel(long handle, byte infoLogLevel)voidsetInfoLogLevel(InfoLogLevel infoLogLevel)SetInfoLogLevelto AbstractLogger.-
Methods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Methods inherited from class org.rocksdb.AbstractNativeReference
dispose, finalize
-
-
-
-
Method Detail
-
initializeNative
protected long initializeNative(long... nativeParameterHandles)
Description copied from class:RocksCallbackObjectConstruct the Native C++ object which will callback to our object methods- Specified by:
initializeNativein classRocksCallbackObject- Parameters:
nativeParameterHandles- An array of native handles for any parameter objects that are needed during construction- Returns:
- The native handle of the C++ object which will callback to us
-
setInfoLogLevel
public void setInfoLogLevel(InfoLogLevel infoLogLevel)
SetInfoLogLevelto AbstractLogger.- Parameters:
infoLogLevel-InfoLogLevelinstance.
-
infoLogLevel
public InfoLogLevel infoLogLevel()
Return the loggers log level.- Returns:
InfoLogLevelinstance.
-
log
protected abstract void log(InfoLogLevel infoLogLevel, java.lang.String logMsg)
-
createNewLoggerOptions
protected long createNewLoggerOptions(long options)
-
createNewLoggerDbOptions
protected long createNewLoggerDbOptions(long dbOptions)
-
setInfoLogLevel
protected void setInfoLogLevel(long handle, byte infoLogLevel)
-
infoLogLevel
protected byte infoLogLevel(long handle)
-
disposeInternal
protected void disposeInternal()
We overrideRocksCallbackObject.disposeInternal()as disposing of a rocksdb::LoggerJniCallback requires a slightly different approach as it is a std::shared_ptr- Overrides:
disposeInternalin classRocksCallbackObject
-
-