简体   繁体   中英

Ambient filter / interceptors for domain classes in Gorm / Grails?

I just integrated a logging concept for my Grails system and used the filter mechanism to log access to my controllers and actions. The good thing is that I can define one filter for all controller and actions.

With domain classes I do only know the interceptor concept where I have to write an interceptor for every individual domain class. Is there a concept similar to filters for domain classes where I can define an interceptor for ALL domain classes?

Many thanks in advance, Joerg.

UPDATE 1: Thank you for the tip on the Audit Logging Plugin by Stefan. The Audit Logging Plugin looks like the easiest alternative but produces too many rows/logs for my taste and does not use the grails/log4j logging system.

Currently, my requirements are:

  1. Log the insert/update/delete for all domain classes (in order to log only the incidents, not every change to every field/column)

  2. Log to the Grails logging system (log4j) in order to log to stdout, individual database tables, or email (The level might be, eg, INFO or TRACE)

  3. Log to a special domain class (db table) in order to build a log visualization / management system on top of it (via Grails controller & actions). Here it would be great to configure if the logs are in the same or another database/grails-app (in order to split the log management system later on).

As far as I know a simple "change" logging can be done via:

  1. Individual log statements in domain classes (requires insert/update/delete events in every domain class)

  2. Define a "Log" Superclass which inherits the insert/update/delete events (makes it hard to make indivudal insert/update/delete events in special domain classes)

  3. Define a Filter for all controllers but only save/update/delete actions (problem: does not log changes to domain classes without an controller or if multiple domain classes are touched in one action)

Hope this helps other. Nevertheless, Did I miss something?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM