在这里找到了一种处理事务日志的方法:
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企业版。任何建议表示赞赏!谢谢!
答案 0 :(得分:1)
显然它不在数据库lib文件中
您需要做的是将其添加到您的maven pom或在此处下载
http://mvnrepository.com/artifact/org.neo4j.app/neo4j-server/2.0.0-M03