0

I'm trying to add data auditing to my Grails project, but it doesn't work. I've read this tutorial on grails site and did everything as described there.

What I have now is a domain class Event looking as simple as this:

class Event {

    static auditable = true;

    String name;

    def onSave = {
        println "event inserted";
    }
    def onChange = {
        println "event changed";
    }
}

and a method in the main controller:

def addEvent = {
    def obj = new Event([name:"Test event 1"]);
    if (obj.save(flush:true)){
        render "addEvent complete for " + obj.toString();}
    else{
        render "addEvent failed for " + obj.toString();
        obj.errors.allErrors.each {
            log.error( it.toString() );
        }
    }
}

I also added auditLog.verbose = true to the Config.groovy file.

Still when I call this method from my browser, the new event is created in DB, but there is nothing in the audit_log table, nor in the console about this happening.

What am I missing here?

svz
  • 4,516
  • 11
  • 40
  • 66
  • Just tried this on a fresh mysql backed grails (2.1.1) project and the code worked as expected. Got the audit entry in the table and 'event inserted' message on the console. Try doing grails clean on your project and then trying again. – uchamp Jan 22 '13 at 11:23
  • @uchamp, Thanks, nice to hear that it's supposed to work at least. Will try to do some magic :) – svz Jan 22 '13 at 11:33

0 Answers0