grails-audit-logging-plugin icon indicating copy to clipboard operation
grails-audit-logging-plugin copied to clipboard

GPAUDITLOGGING-68: Datasource disabled option doesn't appear to work correctly

Open robertoschwald opened this issue 10 years ago • 2 comments

Original Reporter: hollowaybrad Environment: Grails 2.4.3 Version: Grails-AuditLogging 1.0.1 Migrated From: http://jira.grails.org/browse/GPAUDITLOGGING-68

The way the plugin is checking for the auditLog.disabled in the datasource:

if (!application.config.auditLog.disabled && !datastore.config.auditLog.disabled) {

appears to be the application config and not the datasource config, thus the disabled property is not there.

To access the auditLog.disabled property set in my datasource I have to call the datasource by name like : grailsApplication.config.dataSourceName.auditLog

Is there a unit test or anything that validates that the auditLog.disabled = true in the datasource works as intended?

robertoschwald avatar Oct 28 '14 12:10 robertoschwald

roos said: Looked into it and you are correct.

We need to find a way to obtain the dataSource name for the datastore.

robertoschwald avatar Nov 20 '14 07:11 robertoschwald

I've dug into this a little bit. I'm being affected by this issue for an application that is on Grails 2.3.11. We have added a second dataSource that is read-only (its actually a read-replica of our default dataSource), and want to disable audit-logging for the new dataSource.

I'm finding that during "grails run-app" its easy to make it work: the iterator in doWithApplicationContext that walks the org.grails.datastore.mapping.core.Datastore objects (one per dataSource) has a "sessionFactory.targetBean", which has a property "org.grails.internal.SESSION_FACTORY_HOLDER" (or "org.grails.internal.SESSION_FACTORY_HOLDER_${alternateDataSourceName}") which can be parsed to determine whether it represents the default dataSource or another. Once you have that, you can access the per-dataSource configuration value which marks it disabled.

When running in "run-war", these properties do not exist, and I could find no other property that would indicate the dataSource name for a given Datastore in doWithApplicationContext.

I concur there doesn't seem to be a simple way to make this happen in Grails 2.x. Maybe this feature should be removed, or replaced with another configuration method that is workable?

jukin-jerry avatar Oct 30 '17 07:10 jukin-jerry