Enabling Hibernate Envers Audit Logging in OpenMRS

OpenMRS includes Hibernate Envers for audit logging, allowing you to track changes in the database. Hibernate Envers works by creating separate audit tables to track changes to your entities. When an entity is created, updated, or deleted, Envers automatically logs these changes in the corresponding audit table. Each audit entry includes details such as the type of operation (insert, update, delete), the state of the entity, the user who modified it, and a timestamp. This allows you to query and review the history of changes made to your entities over time. Follow the steps below to enable audit logging for your OpenMRS server.


  • OpenMRS Core 2.7.0+: Audit logging is available for servers running version 2.7.0 or later.

How to Enable Auditing

  1. Open the openmrs-runtime.properties file.

  2. Add the following lines:

hibernate.integration.envers.enabled=true hibernate.hbm2ddl.auto=update


  • hibernate.integration.envers.enabled=true: Enables Hibernate Envers auditing for the server.

  • hibernate.hbm2ddl.auto=update: Automatically generates the audit tables. You can disable this property if you prefer to create the audit tables manually.

Configuring Hibernate Envers

You can configure Hibernate Envers by adding properties to the openmrs-runtime.properties file. For example, to change the audit table name suffix, use the org.hibernate.envers.audit_table_suffix property:


You could add a prefix to the audit table name using org.hibernate.envers.audit_table_prefix property:


You can adjust other Envers configurations similarly by adding the appropriate properties to the openmrs-runtime.properties file.

For more detailed information on configuring Envers, refer to the Envers documentation.