Package org.rocksdb

Class Logger

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    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.

    Performance

    There 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 Detail

      • Logger

        public Logger​(Options options)

        AbstractLogger constructor.

        Important: the log level set within the Options instance will be used as maximum log level of RocksDB.

        Parameters:
        options - Options instance.
      • Logger

        public Logger​(DBOptions dboptions)

        AbstractLogger constructor.

        Important: the log level set within the DBOptions instance will be used as maximum log level of RocksDB.

        Parameters:
        dboptions - DBOptions instance.
    • Method Detail

      • initializeNative

        protected long initializeNative​(long... nativeParameterHandles)
        Description copied from class: RocksCallbackObject
        Construct the Native C++ object which will callback to our object methods
        Specified by:
        initializeNative in class RocksCallbackObject
        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
      • 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)