开发者

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

开发者 https://www.devze.com 2023-01-29 17:05 出处:网络
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 an

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, e.g., 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 开发者_Python百科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?


Maybe http://www.grails.org/plugin/audit-logging is what you're looking for.

0

精彩评论

暂无评论...
验证码 换一张
取 消