我已经在我的应用程序中安装了audit-logging插件。grails版本是2.1.1,插件版本是1.0.1。
在我的Config.groovy类中,我添加了以下内容
auditLog {
verbose = true // verbosely log all changed values to db
logIds = true // log db-ids of associated objects.
// Note: if you change next 2 properties, you must update your database schema!
tablename = 'audit_logs' // table name for audit logs.
transactional = false
actorClosure = { request, session ->
org.apache.shiro.SecurityUtils.getSubject()?.getPrincipal()
}在我的域类中,我添加了以下内容
class Survey {
static auditable = true
static final int NO_RUNNING_SURVERY = 0
static final int RUNNING_SURVERY = 1
static final int CALL_NO_Record_SURVEY = 0
static final int CALL_Record_SURVEY = 1
static final int REALTIME_SURVEY = 0
static final int HISTORICAL_SURVEY = 1
static final int STANDARD_SURVERY = 2
String name
String description
int status
} 当我添加、删除和更新一些东西时。
def stopSurvey(Long id) {
def survey = Survey.findById(params['stop'])
survey.status = Survey.NO_RUNNING_SURVERY
redirect(action: "list")
} 它会在每个调用中插入两条记录。
发布于 2014-07-04 14:59:23
@Bertl
我发现了问题,我想,问题出在插件上。我的应用程序使用三个数据库,一个是主数据库,另外两个用于其他目的。我的databSource如下。
dataSource.driverClassName = net.sourceforge.jtds.jdbcx.JtdsDataSource
dataSource.dbCreate = update
dataSource.url = jdbc:jtds:sqlserver://localhost:1433/test
dataSource.username = test
dataSource.password = 123
#TEST1
dataSource_TEST1.driverClassName = net.sourceforge.jtds.jdbcx.JtdsDataSource
dataSource_TEST1.readOnly = true
dataSource_TEST1.url = jdbc:jtds:sqlserver://xxx.xxx.xxx.xxx:1433/test1
dataSource_TEST1.username = test1
dataSource_TEST1.password = 123
# TEST2
dataSource_TEST2.driverClassName = net.sourceforge.jtds.jdbcx.JtdsDataSource
dataSource_TEST2.readOnly = true
dataSource_TEST2.url = jdbc:jtds:sqlserver://xxx.xxx.xxxx.xxx:1433/test2
dataSource_TEST2.username = test2
dataSource_TEST2.password = 123当我只使用test数据源并删除其他dataSources时,它会插入一条记录。当我使用两个数据源时,它会在audit logging表中插入两个reocrd。这与我使用这三个数据源,然后在审计日志中插入三条记录时相同。我需要所有三个数据库,但这会产生问题。我现在该怎么做?
发布于 2014-07-02 19:36:16
在这里也没有看到这种行为。在许多项目中使用此插件。您可以设置verbose=false并重新测试吗?如果问题也发生了,这意味着事件可能不只触发一次。
一个小的测试应用程序就很棒了。
顺便说一下:我们在插件项目包含的测试应用程序(audit- test )中使用spock测试来检查audit_log表中存储了多少事件。因此,我假设您的应用程序中存在边缘情况或特定问题。
https://stackoverflow.com/questions/24241355
复制相似问题