问题
I am getting unwanted query log from spring neo4j like following
25-08-2018 23:47:07.597 [restartedMain] INFO o.n.o.d.bolt.request.BoltRequest.executeRequest -
Request: MATCH (n:`OntoCategory`) WHERE n.`name` = { `name_0` } WITH n RETURN n,[ [ (n)-[r_h1:`HasSynonym`]->(o1:`OntoSynonyms`) | [ r_h1, o1 ] ] ], ID(n) with params {name_0=Breakfast Items}
25-08-2018 23:47:07.610 [restartedMain] INFO o.n.o.d.bolt.request.BoltRequest.executeRequest -
I am using following logging properties in my application.properties
Is there anything I've missed to add. I'm using spring boot version 2.0.3
logging.level.root=info
logging.path=path
logging.file=${logging.path}/log.log
logging.pattern.file=%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n
logging.pattern.console=%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %n%highlight%msg%n
Following two log properties are added from following post which doesn't change anything
log4j.category.org.springframework.data.neo4j=DEBUG
log4j.category.org.springframework.data.neo4j.support.query=DEBUG`
回答1:
The logging of the cypher query is done by BoltRequest
class in neo4j-ogm. So that's where you should be changing the logging level like the following (to keep other logging configuration unaffected):
logging.level.org.neo4j.ogm.drivers.bolt.request.BoltRequest=WARN
Note, however that, as the logging level in this class has been changed very recently according to your request (per #530, by commit f37a78e - logging level of cypher queries downgraded to DEBUG), if you upgrade your SDN installation in your project, you may just be automatically getting rid of the query logs w/o making this adjustment to logging configuration
(I currently have neo4g-ogm-bolt-driver-3.1.4.jar
in my project, and I don't get the queries logged).
回答2:
log4j.category.org.springframework.data.neo4j.support.query=DEBUG
This entry in the log configuration, logs the query. To avoid logging query to the log files remove this entry.
回答3:
If you set the log4j log level to DEBUG
, then all log messages at DEBUG
level and above (which includes INFO
) will be logged.
To prevent INFO
level messages from being logged, you should set the log level to WARN
(or an even higher level).
回答4:
Since you have this configuration :
logging.level.root=info
The root log level will be info, but if another level is different, it will override it for this log.
So, to have the following behaviour :
- Neo4j log will be displayed if its level is WARN or higher (so, no request log)
- Every other log in your app will be displayed if its level is INFO or higher
What you want is to do this :
logging.level.root=info
log4j.category.org.springframework.data.neo4j=WARN
log4j.category.org.springframework.data.neo4j.support.query=WARN
回答5:
By adding this line in application.properties queries is not logging in console.Its working
logging.level.org.neo4j.ogm.drivers=OFF
来源:https://stackoverflow.com/questions/52019947/how-to-disable-log-in-spring-data-neo4j