问题
I would see the below sample audit logging which MarkLogic provides
Sample logging : 2012-03-26 10:55:53.735 event=amp-usage;
function=http://marklogic.com/xdmp/admin:read-config-file;
uri=/MarkLogic/admin.xqy; database=filesystem;
success=true; user=admin; roles=admin;
Can I customize this message by adding few more details highlighted below like this
Sample logging : 2012-03-26 10:55:53.735 event=amp-usage; function=http://marklogic.com/xdmp/admin:read-config-file; uri=/MarkLogic/admin.xqy; database=filesystem;success=true; user=admin; roles=admin; Received request for Tenant Id=xxxxx called by source id=xxxx Web. Request ID xxxx
回答1:
The purpose of audit logging is to be generated by MarkLogic, and not depend on the application, nor being influenced by it in any way. It should be an independent source to verify/audit the database activity.
I think Trace Event logging is what you are looking for. There are built-in Trace Events, like URL Rewrite:
http://docs.marklogic.com/guide/app-dev/appserver-control#id_25611
And you can use fn:trace to generate custom trace events. Make sure to activate trace events on the Diagnostics page of the appropriate group in the Admin interface, and to add on that same page all relevant trace events to the list of events that should get logged.
HTH!
回答2:
Of course, this can be achieved.
Create a module (say activity-log.xqy) which creates and insert log document [xdmp:document-insert()] into audit database.
Call it from another module (say, logger.xqy) which spawns the logging task [xdmp:spawn()], here you will specify the database name, so give audit in that.
来源:https://stackoverflow.com/questions/30249453/marklogic-audit-log