Query logging missing with new Golang-neo4j-driver 1.8

Hello,

I'm using Neo4j 3.5.12-enterprise via Docker Image with Golang. Recently, I made an upgrade to the new Go Driver 1.8.0, from the older 1.7.4. The new go mod driver without any seabolt dependencies was a sight for sore eyes. I kept my Neo4j Server version at 3.5.12, since the 1.8 driver is compatible with it, and not just 4.0.

My query is regarding any changes to the driver logs. In 1.7.4, the driver logs (in DEBUG level) used to provide the exact cypher query being run:

INFO   : 2020/06/25 09:13:39.837654 [pool-1]: Acquiring connection from the pool towards localhost:7687
INFO   : 2020/06/25 09:13:39.835535 [pool-1]: Acquiring connection from the pool towards localhost:7687
INFO   : 2020/06/25 09:13:39.837761 [pool-1]: Acquiring connection from the pool towards localhost:7687
INFO   : 2020/06/25 09:13:39.845082 [addr]: Host resolved to 2 IP addresses
INFO   : 2020/06/25 09:13:39.845165 [conn-1]: Opening IPv6 connection to ::1 at port 7687
WARNING: 2020/06/25 09:13:39.880877 [conn-1]: Openssl reported error 'self signed certificate' with code '18' when establishing trust, but resuming handshake since trust verification is set to be skipped
DEBUG  : 2020/06/25 09:13:39.881427 [conn-1]: Openssl established trust
INFO   : 2020/06/25 09:13:39.896406 [conn-1]: Remote endpoint is ::1:7687
INFO   : 2020/06/25 09:13:39.896421 [conn-1]: Local endpoint is ::1:51178
INFO   : 2020/06/25 09:13:39.896535 [conn-1]: Performing handshake
INFO   : 2020/06/25 09:13:39.896607 [conn-1]: (Sent 20 of 20 bytes)
INFO   : 2020/06/25 09:13:39.905297 [conn-1]: Received 4 of 4 bytes
INFO   : 2020/06/25 09:13:39.905349 [conn-1]: <SET protocol_version=3>
INFO   : 2020/06/25 09:13:39.905385 [conn-1]: <CONNECTED>
INFO   : 2020/06/25 09:13:39.905399 [conn-1]: Initialising connection
DEBUG  : 2020/06/25 09:13:39.905428 [conn-1]: C[0] HELLO [{principal: neo4j, credentials: ********, scheme: basic, user_agent: Go Driver/1.7}]
INFO   : 2020/06/25 09:13:39.905498 [conn-1]: (Sent 81 of 81 bytes)
INFO   : 2020/06/25 09:13:39.916627 [conn-1]: Received 49 of 2..8192 bytes
DEBUG  : 2020/06/25 09:13:39.916669 [conn-1]: S[0] SUCCESS [{server: Neo4j/3.5.12, connection_id: bolt-14}]
INFO   : 2020/06/25 09:13:39.916676 [conn-1]: <SET server="Neo4j/3.5.12">
INFO   : 2020/06/25 09:13:39.916680 [conn-1, bolt-14]: <SET connection_id="bolt-14">
INFO   : 2020/06/25 09:13:39.916683 [conn-1, bolt-14]: <READY>
INFO   : 2020/06/25 09:13:39.916716 [addr]: Resolving address localhost:7687
DEBUG  : 2020/06/25 09:13:39.916749 [conn-1, bolt-14]: C[1] RUN [MATCH(r:Role) 
                                                                WHERE r.Type="Admin" 
                                                                RETURN r, {}, {mode: r}]
DEBUG  : 2020/06/25 09:13:39.916773 [conn-1, bolt-14]: C[2] PULL_ALL []
INFO   : 2020/06/25 09:13:39.916856 [conn-1, bolt-14]: (Sent 84 of 84 bytes)

However, after 1.8, the same DEBUG level logs do not contain the cypher query being run:

DEBUG  : 2020/06/25 09:23:17.823279 sess 28:Created
DEBUG  : 2020/06/25 09:23:17.823303 pool 1:Trying to borrow connection from [localhost:7687]
DEBUG  : 2020/06/25 09:23:17.835896 pool 1:Returning connection to localhost:7687 {alive:true}
DEBUG  : 2020/06/25 09:23:17.835922 sess 27:Closed
[2020-06-25 09:23:17]  INFO Response Duration=29 Method=GET Size=56 StatusCode=200 URL=/app/list
[2020-06-25 09:23:17]  INFO Request Client=192.168.0.94:52613 Method=GET Referrer=http://localhost:5000/apps URL=/users/config?userId=admin User-Agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36
DEBUG  : 2020/06/25 09:23:17.843868 sess 29:Created
DEBUG  : 2020/06/25 09:23:17.843892 pool 1:Trying to borrow connection from [localhost:7687]
DEBUG  : 2020/06/25 09:23:17.851775 pool 1:Returning connection to localhost:7687 {alive:true}
DEBUG  : 2020/06/25 09:23:17.851798 sess 28:Closed
[2020-06-25 09:23:17]  INFO Response Duration=28 Method=GET Size=17 StatusCode=200 URL=/admin/admin
DEBUG  : 2020/06/25 09:23:17.897915 pool 1:Returning connection to localhost:7687 {alive:true}
DEBUG  : 2020/06/25 09:23:17.897952 sess 26:Closed
[2020-06-25 09:23:17]  INFO Response Duration=88 Method=GET Size=17 StatusCode=200 URL=/admin/exists
DEBUG  : 2020/06/25 09:23:17.923441 pool 1:Returning connection to localhost:7687 {alive:true}
DEBUG  : 2020/06/25 09:23:17.923459 sess 29:Closed
DEBUG  : 2020/06/25 09:23:17.923493 sess 30:Created
DEBUG  : 2020/06/25 09:23:17.923510 pool 1:Trying to borrow connection from [localhost:7687]
DEBUG  : 2020/06/25 09:23:17.984386 pool 1:Returning connection to localhost:7687 {alive:true}
DEBUG  : 2020/06/25 09:23:17.984409 sess 30:Closed

I went through the driver docs, expecting to find some way to turn it back on, but didn't. Also tried with TLS off, because I wasn't providing any certificates. But still no query logging.
Is there anyway to turn it back on, in the driver settings? Or has it been removed in 1.8?

I'm facing the same situation where enabling the neo4j.DEBUG flag no longer prints the query in the logs.
Currently using Go 1.14.4 with driver github.com/neo4j/neo4j-go-driver v1.8.0. Sample logs -

INFO   : 2020/06/27 15:50:54.596862 bolt-25@graph-db:7687/v3:Connected
INFO   : 2020/06/27 15:50:54.596876 boltconnect@graph-db:7687:Connected to Neo4j/3.5.14
DEBUG  : 2020/06/27 15:50:54.898411 pool 3:Returning connection to graph-db:7687 {alive:true}
DEBUG  : 2020/06/27 15:50:54.898477 sess 1:Closed
DEBUG  : 2020/06/27 15:50:54.905337 sess 1:Closed
DEBUG  : 2020/06/27 15:50:54.923458 sess 2:Created
DEBUG  : 2020/06/27 15:50:54.923495 pool 3:Trying to borrow connection from [graph-db:7687]
DEBUG  : 2020/06/27 15:50:55.015395 pool 3:Returning connection to graph-db:7687 {alive:true}
DEBUG  : 2020/06/27 15:50:55.015406 sess 2:Closed
DEBUG  : 2020/06/27 15:50:55.015424 sess 2:Closed

Previously using Go 1.12.5 with driver github.com/neo4j/neo4j-go-driver v1.7.4
(logs for this configuration are similar to the sample posted by @visakh.girish9 )

Any idea how to turn query printing back on?

It seems that the functionality is lost with v1.8, and the driver will no longer log the queries. The closest you can get to it is by implementing your own logger, or by using this: https://neo4j.com/docs/operations-manual/current/monitoring/logging/query-logging/.

1 Like

Hello,

Apologies for the late reply, but the functionality is now back, and can be enabled per session: GitHub - neo4j/neo4j-go-driver: Neo4j Bolt Driver for Go!