Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
robertoschwald opened this issue Oct 28, 2014 · 2 comments

Comments

@robertoschwald
Copy link
Member

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
Copy link
Member Author

roos said:
Looked into it and you are correct.

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

@jukin-jerry
Copy link

jukin-jerry commented Oct 30, 2017

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants