Audit4j 是一个用来构建高度可插入、嵌入式、异步、安全、注解驱动和高性能的审计框架,基于 Java 开发,也使用 Scala 和 Groovy 调用。Audit4j 用来审计服务器、应用和数据库事件。
示例代码:
String actor = MyApplicationContext.getAuthanticatedUser(); EventBuilder builder = new EventBuilder(); builder.addActor(actor).addAction("myMethod"). addField("myParam1Name", myParam1).addField("myParam2Name", myParam2); AuditManager manager = AuditManager.getInstance(); manager.audit(builder.build()); public void myMethod(String myParam1, Object myParam2) { String actor = MyApplicationContext.getAuthanticatedUser(); AuditManager manager = AuditManager.getInstance(); manager.audit(new AuditEvent(actor, "myMethod", new Field("myParam1Name", myParam1), new Field("myParam2Name", myParam2))); }