To control logging in Neo4j embedded, use the Neo4j embedded logging framework.
Neo4j embedded provides logging via its own org.neo4j.logging.Log
layer, and does not natively use any existing Java logging framework.
All logging events produced by Neo4j have a name, a level and a message.
The name is a FQCN (fully qualified class name).
Neo4j uses the following log levels:
| For serious errors that are almost always fatal |
| For events that are serious, but not fatal |
| Informational events |
| Debugging events |
To enable logging, an implementation of org.neo4j.logging.LogProvider
must be provided to the GraphDatabaseFactory
,
as follows:
LogProvider logProvider = new MyCustomLogProvider( output ); graphDb = new GraphDatabaseFactory().setUserLogProvider( logProvider ).newEmbeddedDatabase( DB_PATH );
Neo4j also includes a binding for SLF4J, which is available in the neo4j-slf4j
library jar.
This can be obtained via Maven:
<project> ... <dependencies> <dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j-slf4j</artifactId> <version>3.1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> ... </dependencies> ... </project>
To use this binding, simply pass an instance of org.neo4j.logging.slf4j.Slf4jLogProvider
to the GraphDatabaseFactory
,
as follows:
graphDb = new GraphDatabaseFactory().setUserLogProvider( new Slf4jLogProvider() ).newEmbeddedDatabase( DB_PATH );
All log output can then be controlled via SLF4J configuration.