有没有办法像 Hibernate 一样在 Neo4J 上记录查询?
因此,场景如下:
- 我有一个在本地运行的 Neo4J 服务器,其中包含一些数据
- 我有一个使用
spring-data-neo4j
的 Web 应用程序
下面的代码基于示例代码 Cineasts:
public interface CrewRepository extends GraphRepository<Crew> {
Iterable<Crew> findByNameLike(String name);
@Query("start thinker=node({0}) match thinker-[:crews]-crews return crews")
Set<Crew> findByThinker(Long thinkerId);
}
这里没有新闻。问题是:查询 findByNameLike
不起作用,而 findByThinker
却起作用。
我已经多次修改了我的日志配置文件 - 最终版本如下 - 但是,无论我尝试什么,我都看不到任何正在记录的查询 - 无论是在我的日志文件上还是在服务器上。
<logger name="org.neo4j">
<level value="DEBUG" />
<appender-ref ref="console" />
</logger>
<logger name="org.springframework.data.neo4j">
<level value="DEBUG" />
<appender-ref ref="console" />
</logger>
<root>
<priority value="error" />
<appender-ref ref="console" />
</root>
我想要的只是记录查询,这样我就可以查看它是否是 spring-data-neo4j 上的错误或者我是否遗漏了某些内容......我已经查看了两者的文档和代码示例并找不到任何具体的东西。
有什么帮助吗?谢谢你!
So, here is the scenario:
- I have Neo4J server running locally with some data in it
- I have a web app using
spring-data-neo4j
The following code is based on the example code Cineasts:
public interface CrewRepository extends GraphRepository<Crew> {
Iterable<Crew> findByNameLike(String name);
@Query("start thinker=node({0}) match thinker-[:crews]-crews return crews")
Set<Crew> findByThinker(Long thinkerId);
}
No news here. The problem is: the query findByNameLike
doesn't work whereas the findByThinker
does.
I have modified my log configuration file many times - final version is the one below - but, doesn't matter what I try, I can't see any queries being logged - either on my log file or on the server.
<logger name="org.neo4j">
<level value="DEBUG" />
<appender-ref ref="console" />
</logger>
<logger name="org.springframework.data.neo4j">
<level value="DEBUG" />
<appender-ref ref="console" />
</logger>
<root>
<priority value="error" />
<appender-ref ref="console" />
</root>
All I want is the log the queries so I can see if it's a bug on spring-data-neo4j
or if I'm missing something... I have looked through the documentation of both, code examples and couldn't find anything that specific.
Any help? Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过将以下行添加到 log4j.xml 来启用查询日志记录:
You can enable query logging by adding the following lines to your log4j.xml:
如果有人来到这里寻找如何在通过 REST API 远程访问 Neo4j Server 时记录查询,请使用
如果您使用 Spring Data Neo4j 并希望查看与您的 DAO 方法相对应的派生查询,
If anyone lands here looking for how to log queries when Neo4j Server is accessed remotely over the REST API, use
If you're using Spring Data Neo4j and want to see the derived queries corresponding to your DAO methods,