### Berkeley DB Reference Guide: Logging Subsystem |

# Berkeley DB and logging

The logging subsystem is the logging facility used by Berkeley DB. It is largely Berkeley DB specific, although it is potentially useful outside of the Berkeley DB package for processes wanting write-ahead logging support. Applications wanting to rework the log for their own purposes will almost certainly need to make source code modifications to the Berkeley DB code base.

A log can be shared by any number of processes and threads within processes. The DBENV->open interface opens, and if necessary, creates, a log. When the log is no longer in use, it should be closed, using the DBENV->close interface.

Individual log entries are identified by log sequence numbers. Log sequence numbers are stored in an opaque object, a DB_LSN.

The log_put interface is used to append new log records to the log. Optionally, the DB_CHECKPOINT flag can be used to cause any log record to include checkpoint information, such that the log is consistent to that point and recoverable after a system or application failure. The log_get interface is used to retrieve log records from the log.

There are additional interfaces for integrating the log subsystem with a transaction processing system:

log_register and log_unregister
  These interfaces associate files with identification numbers. These identification numbers are logged so that log recovery correctly associates database changes with the appropriate files.

log_flush
  Flushes the log up to a particular log sequence number.

log_compare
  Allows applications to compare any two log sequence numbers.

log_file
  Maps a log sequence number to the specific log file which contains it.

log_archive
  Returns various sets of log file names. These interfaces are used for database administration, e.g., to determine if log files may be removed from the system.

log_stat
  The display db_stat utility uses the log_stat interface to display statistics about the log.

DBENV->remove
  Finally, the log meta-information (but not the log files themselves) may be removed using the DBENV->remove interface.

Copyright Sleepycat Software