openmrs-core
openmrs-core copied to clipboard
OMRS-131: Detailed Audit Logging
Description of what I changed
This adds Hibernate Envers to the OpenMRS to enable audit logging.
Added hibernate.integration.envers.enabled=false
property to disable audit logging by default. We should enable it from the module.
Issue I worked on
see https://openmrs.atlassian.net/browse/OMRS-131
Checklist: I completed these to help reviewers :)
-
[x] My IDE is configured to follow the code style of this project.
No? Unsure? -> configure your IDE, format the code and add the changes with
git add . && git commit --amend
-
[ ] I have added tests to cover my changes. (If you refactored existing code that was well tested you do not have to add tests)
No? -> write tests and add them to this commit
git add . && git commit --amend
-
[x] I ran
mvn clean package
right before creating this pull request and added all formatting changes to my commit.No? -> execute above command
-
[x] All new and existing tests passed.
No? -> figure out why and add the fix to your commit. It is your responsibility to make sure your code works.
-
[x] My pull request is based on the latest changes of the master branch.
No? Unsure? -> execute command
git pull --rebase upstream master
@dkayiwa I was able to fix the old issue by changing the hibernate dialect from MySQLDialect to MySQL5Dialect.
@wikumChamith i tried to locally run the changes in this pull request after adding this to my runtime properties file hibernate.integration.envers.enabled=true
but not a single audit log table was created. Can you look into this too?
@dkayiwa you need to add both of these properties to the runtime properties file.
hibernate.integration.envers.enabled=true
hibernate.hbm2ddl.auto=update
Is there a way we can avoid this? hibernate.hbm2ddl.auto=update
I don't think there are any other viable ways. This is the recommended approach in the Hibernate documentation: https://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html#envers
@wikumChamith is this ready?
@wikumChamith is this ready?
Still, the application does not generate audit tables for user_properties
. I'll give it another try and let you know.
I'll give it another try and let you know.
Anxiously looking forward to the update. 😊
@wikumChamith can you start on a wiki page with steps of how to set up auditing that we shall use when this is merged?
@dkayiwa I created a wiki page: https://openmrs.atlassian.net/wiki/spaces/docs/pages/113999876/Enabling+Hibernate+Envers+Audit+Logging+in+OpenMRS
I'm not entirely sure if I created it in the correct section :sweat_smile:. Could you please take a look?
Thanks, let me take a look. Did you figure out the issue with user_properties
? If not yet, can you just move on with the rest of the tables?
Can you also add to the documentation what module developers would need to do if they want their tables to also be audited?
Thanks, let me take a look. Did you figure out the issue with
user_properties
? If not yet, can you just move on with the rest of the tables?
All the core tables except the 'user_properties' are working fine. The only solution I found so far is to introduce a separate entity for UserProperties. I don't feel comfortable it with because we have to do a lot of code changes.
Can you forget about user properties and we proceed?
Secondly, when i looked at the log tables, i did not see which user made the change.
I am totally happy to forget the user properties :joy:
Secondly, when i looked at the log tables, i did not see which user made the change.
Those data are in the OpenMRSRevisionEntity table.
Seen them. Can you now proceed with the next steps?
Seen them. Can you now proceed with the next steps?
Could you please clarify what the next steps are?
A module for visualising those logs to the user.
A module for visualising those logs to the user.
Shouldn't we merge this before proceeding with the module??