在这里找到了一种处理事务日志的方法:
https://gist.github.com/psuman/3118371
我移到这里的代码:
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.event.TransactionData;
import org.neo4j.graphdb.event.TransactionEventHandler;
public class WarehouseTransactionEventHandler implements TransactionEventHandler<String> {
private static Logger log = Logger
.getLogger(WarehouseTransactionEventHandler.class);
public void afterCommit(TransactionData data, String state) {
Iterable<Node> createdNodes = data.createdNodes();
for(Node n: createdNodes) {
log.info("AfterCommit ########: created node:" + n.getId());
}
}
public void afterRollback(TransactionData data, String state) {
// TODO Auto-generated method stub
}
public String beforeCommit(TransactionData data) throws Exception {
Iterable<Node> createdNodes = data.createdNodes();
for(Node n: createdNodes) {
log.info("BeforeCommit ######: created node:" + n.getId());
}
return null;
}
}
但是,当我将它添加为导入时,它找不到应该在 org.neo4j.server.logger 中的 Logger 对象。我在 server-api-2.0.0-M03.jar 库中能找到的只有助手、插件或休息。我正在使用 neo4j 2.0 M3 企业版。任何建议表示赞赏!谢谢!