Closed yangziwen closed 6 years ago
Hi @yangziwen
You can use use Layouts for the json layout. It is not such hard to write your own filter or use CustomizableLayout . You can even filter unwanted information using a custom layout.
Thanks so much for your reply.
Currently I import a customized ObjectSerializer via audit4j's commands configuration, and use it working together with CustomizableLayout to output json format audit fields to console or file.
But I still can not persist these fields to database as complete json format, because AuditLogDaoImpl#writeEvent method simply concat all fields with ',' as separator, then I can not eliminate the last ',' and add the outmost curly braces before insert the content to database.
Should I implement DatabaseAuditHandler and AuditLogDaoImpl by myself, or is there any other elegant way to solve the problem?
You are absolutely correct. That is a limitation of DB handler and you need to use a custom DB handler to insert the text as string. In the meantime I'll find a solution to fix this issue.
I would really appreciate if you can share your JSON serializer implementation. We do accept pul requests.
This is fixed
I am also looking for similar, Values for Fields are not very readable for complex objects (e.g. beans or collection etc), is there ways to customize that?
Thanks
Got it, just for confirmation and may be useful for someone like me: We can set AnnotationTransformer to use specific ObjectSerializer, like ObjectToJsonSerializer in this instance.
Since the annotationTransformer property in SpringAudit4jConfig is still not available in the latest release (2.4.1) of audit4j-spring, do you have any plan to give the next release in the near future? @janithb
audit4j 2.5.0 is already release. this issue is already fixed in 2.5.0 version.
Hi guys ( @janithb @yangziwen ), there are a documentation somewhere about save the content of elements column in json format? Thanks!
Hi,
Could someone provide me an example configuration to log elements field on audit table store json string of an object?
Never mind, I have figured it out. It's as simple as this...
audit4jConfig.setAnnotationTransformer(new DefaultAnnotationTransformer(new ObjectToJsonSerializer()));
Dear author
I'm trying to find a way to save the content of elements column in json format, because I only care about values and don't want to save too many infos about objects' types.
It seems hard to override method behaviors of some important classes(such as DefaultAnnotationTransformer). Do you have any suggestion?